Jump to content
MakeWebGames

Index.php Help Please


Seker

Recommended Posts

Okay, so a little background first. I've just recently decided I'd like to take up the challenge of creating and running a game. I chose purchase a V1 license for several reasons. The most obvious being the cost, but I also thought starting with a very basic base would only force me to figure out php coding faster. I've been perusing these forums the past few days, and have found a lot of resources that have helped me immensely so far.

Anyway. On to my problem. I'm using a couple of mods in my index.php and they just aren't seeming to mesh with a simple table layout. Included with the standard code are some display options for attack stats, as well as displaying the player's bank at the bottom of the screen. Now, when I just add a table with the stats listed anywhere on the page, I didn't have any errors. However, when I tried to add tables around the stats to mesh with the rest of the layout, I get this error:

Parse error: syntax error, unexpected '<' in /home/drewsch1/public_html/test/index.php on line 112

I was wondering if anyone would just be willing to do quick scan and point out any obvious problems I'm missing. I know it's messy as all get out, and I appreciate anyone taking a minute to help.

Here's the section of code:

 

break;

default:
<span class="highlight">index</span>();
break;
}

}
else

 

And here's the full page:

 

<?php
$housequery=1;
session_start();
require "global_func.php";
if($_SESSION['loggedin']==0) { header("Location: login.php");exit; }
$userid=$_SESSION['userid'];
require "header.php";
$h = new headers;
$h->startheaders();
include "mysql.php";
global $c;
$is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error());
$ir=mysql_fetch_array($is);
check_level();
$fm=money_formatter($ir['money']);
$cm = money_formatter($ir['crystals'], '');
$lv=date('F j, Y, g:i a',$ir['laston']);
$h->userdata($ir,$lv,$fm,$cm);
$h->menuarea();
$exp=(int)($ir['exp']/$ir['exp_needed']*100);
$exp_n=(int)($ir['exp_needed']);


print <<<OUT
<table cellspacing="1" border="1" cellpadding="3" class="table" width="70%">
<tr><td colspan="2"><b>General Information</b></td></tr>
{$geninf}
<tr>
<td><b>Name:</b> {$ir['username']}</td>
<td><b>Crystals:</b> {$cm}</td>
</tr>
<tr>
<td><b>Level:</b> {$ir['level']}</td>
<td><b>Exp:</b> {$exp}%  ({$exp}/{$exp_n})</td>
</tr>
<tr>
<td><b>Money:</b> $fm</td>
<td><b>HP:</b> {$ir['hp']}/{$ir['maxhp']}</td>
</tr></br>
OUT;


$ts=$ir['strength']+$ir['agility']+$ir['guard']+$ir['labour']+$ir['IQ'];
$ir['strank']=get_rank($ir['strength'],'strength');
$ir['agirank']=get_rank($ir['agility'],'agility');
$ir['guarank']=get_rank($ir['guard'],'guard');
$ir['labrank']=get_rank($ir['labour'],'labour');
$ir['IQrank']=get_rank($ir['IQ'],'IQ');
$tsrank=get_rank($ts,'strength+agility+guard+labou  r+IQ');
$ir['strength']=number_format($ir['strength']);
$ir['agility']=number_format($ir['agility']);
$ir['guard']=number_format($ir['guard']);
$ir['labour']=number_format($ir['labour']);
$ir['IQ']=number_format($ir['IQ']);
$ts=number_format($ts);


print <<<OUT
<tr>
<td colspan="2"><b>Stats Info</b></td></tr>
<tr>
<td><b>Strength:</b> {$ir['strength']} [Ranked: {$ir['strank']}]</td>
<td><b>Agility:</b> {$ir['agility']} [Ranked: {$ir['agirank']}]</td>
</tr>
<tr>
<td><b>Guard:</b> {$ir['guard']} [Ranked: {$ir['guarank']}]</td>
<td><b>Labour:</b> {$ir['labour']} [Ranked: {$ir['labrank']}]</td>
</tr>
<tr>
<td><b>IQ: </b> {$ir['IQ']} [Ranked: {$ir['IQrank']}]</td>
<td><b>Total stats:</b> {$ts} [Ranked: $tsrank]</td>
</tr>
</table>
OUT;

print <<<OUT
<table cellspacing="1" border="1" cellpadding="3" class="table" width="70%">
<tr><td colspan="2"><b>Attack Statistics</b></td></tr>
<tr>
<td><b>Total Attacks:</b> {$r['atotal']}</td>
<td><b>Attacks Won:</b> {$r['awon']}</td>
</tr>
<tr>
<td><b>Attacks Lost: {$r['alost']}</td>
<td><b>Times Attacked: {$r['tattacked']}</td>
</tr>
<tr>
<td><b>People Left: {$r['pleft']}</td>
<td><b>People Hospilatized: {$r['phosp']}</td>
</tr>
<tr>
<td><b>People Mugged: {$r['pmugged']}</td>
<td><b>Money Mugged: \${$r['mmugged']}</td>
</tr>
</table>
OUT;

print "<h3>Bank</h3>";
if($ir['bankmoney']>-1)
{
switch($_GET['action'])
{
case "deposit":
deposit();
break;

case "withdraw":
withdraw();
break;

default:
<span class="highlight">index</span>();
break;
}

}
else
{
if(isset($_GET['buy']))
{
if($ir['money']>19999)
{
print "Congratulations, you bought a bank account for \$20,000!

<a href='index.php'>Start using my account</a>";
mysql_query("UPDATE users SET money=money-20000,bankmoney=0 WHERE userid=$userid",$c);
}
else
{
print "You do not have enough money to open an account.
<a href='index.php'>Back</a>";
}
}
else
{
print "Open a bank account today, just \$20,000!

<a href='index.php?buy'> Yes, sign me up!</a>";
}
}
function <span class="highlight">index</span>()
{
global $ir,$c,$userid,$h;
print "\n<b>You currently have \${$ir['bankmoney']} in the bank.</b>

At the end of each day, your bank balance will go up by 0.3%.

<table width='75%' border='2' bordercolor='#lime'> <tr> <td width='50%'><b>Deposit Money</b>

It will cost you 0% of the money you deposit, rounded up. The maximum fee is \$0.<form action='<span class="highlight">index</span>.php?action=deposit' method='post'>
Amount: <input type='text' name='deposit' value='{$ir['money']}' />

<input type='submit' value='Deposit' /></form></td> <td>
<b>Withdraw Money</b>

There is no fee on withdrawals.<form action='<span class="highlight">index</span>.php?action=withdraw' method='post'>
Amount: <input type='text' name='withdraw' value='{$ir['bankmoney']}' />

<input type='submit' value='Withdraw' /></form></td> </tr> </table>";
}
function deposit()
{
global $ir,$c,$userid,$h;
$_POST['deposit']=abs((int) $_POST['deposit']);
if($_POST['deposit'] > $ir['money'])
{
print "You do not have enough money to deposit this amount.";
}
else
{
$fee=ceil($_POST['deposit']*0/100);
if($fee > 0) { $fee=0; }
$gain=$_POST['deposit']-$fee;
$ir['bankmoney']+=$gain;
mysql_query("UPDATE users SET bankmoney=bankmoney+$gain, money=money-{$_POST['deposit']} where userid=$userid",$c);
print "You hand over \${$_POST['deposit']} to be deposited, 

after the fee is taken (\$$fee), \$$gain is added to your account. 

<b>You now have \${$ir['bankmoney']} in the bank.</b>

<a href='index.php'> Back</a>";
}
}
function withdraw()
{
global $ir,$c,$userid,$h;
$_POST['withdraw']=abs((int) $_POST['withdraw']);
if($_POST['withdraw'] > $ir['bankmoney'])
{
print "You do not have enough banked money to withdraw this amount.";
}
else
{

$gain=$_POST['withdraw'];
$ir['bankmoney']-=$gain;
mysql_query("UPDATE users SET bankmoney=bankmoney-$gain, money=money+$gain where userid=$userid",$c);
print "You ask to withdraw $gain, 

the banking lady grudgingly hands it over. 

<b>You now have \${$ir['bankmoney']} in the bank.</b>

<a href='index.php'> Back</a>";
}
}
$h->endpage();
?>
Link to comment
Share on other sites

Okay, so a little background first. I've just recently decided I'd like to take up the challenge of creating and running a game. I chose purchase a V1 license for several reasons. The most obvious being the cost, but I also thought starting with a very basic base would only force me to figure out php coding faster. I've been perusing these forums the past few days, and have found a lot of resources that have helped me immensely so far.

Anyway. On to my problem. I'm using a couple of mods in my index.php and they just aren't seeming to mesh with a simple table layout. Included with the standard code are some display options for attack stats, as well as displaying the player's bank at the bottom of the screen. Now, when I just add a table with the stats listed anywhere on the page, I didn't have any errors. However, when I tried to add tables around the stats to mesh with the rest of the layout, I get this error:

Parse error: syntax error, unexpected '<' in /home/drewsch1/public_html/test/index.php on line 112

I was wondering if anyone would just be willing to do quick scan and point out any obvious problems I'm missing. I know it's messy as all get out, and I appreciate anyone taking a minute to help.

Here's the section of code:

 

break;

default:
<span class="highlight">index</span>();
break;
}

}
else

 

And here's the full page:

 

<?php
$housequery=1;
session_start();
require "global_func.php";
if($_SESSION['loggedin']==0) { header("Location: login.php");exit; }
$userid=$_SESSION['userid'];
require "header.php";
$h = new headers;
$h->startheaders();
include "mysql.php";
global $c;
$is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error());
$ir=mysql_fetch_array($is);
check_level();
$fm=money_formatter($ir['money']);
$cm = money_formatter($ir['crystals'], '');
$lv=date('F j, Y, g:i a',$ir['laston']);
$h->userdata($ir,$lv,$fm,$cm);
$h->menuarea();
$exp=(int)($ir['exp']/$ir['exp_needed']*100);
$exp_n=(int)($ir['exp_needed']);


print <<<OUT
<table cellspacing="1" border="1" cellpadding="3" class="table" width="70%">
<tr><td colspan="2"><b>General Information</b></td></tr>
{$geninf}
<tr>
<td><b>Name:</b> {$ir['username']}</td>
<td><b>Crystals:</b> {$cm}</td>
</tr>
<tr>
<td><b>Level:</b> {$ir['level']}</td>
<td><b>Exp:</b> {$exp}%  ({$exp}/{$exp_n})</td>
</tr>
<tr>
<td><b>Money:</b> $fm</td>
<td><b>HP:</b> {$ir['hp']}/{$ir['maxhp']}</td>
</tr></br>
OUT;


$ts=$ir['strength']+$ir['agility']+$ir['guard']+$ir['labour']+$ir['IQ'];
$ir['strank']=get_rank($ir['strength'],'strength');
$ir['agirank']=get_rank($ir['agility'],'agility');
$ir['guarank']=get_rank($ir['guard'],'guard');
$ir['labrank']=get_rank($ir['labour'],'labour');
$ir['IQrank']=get_rank($ir['IQ'],'IQ');
$tsrank=get_rank($ts,'strength+agility+guard+labou  r+IQ');
$ir['strength']=number_format($ir['strength']);
$ir['agility']=number_format($ir['agility']);
$ir['guard']=number_format($ir['guard']);
$ir['labour']=number_format($ir['labour']);
$ir['IQ']=number_format($ir['IQ']);
$ts=number_format($ts);


print <<<OUT
<tr>
<td colspan="2"><b>Stats Info</b></td></tr>
<tr>
<td><b>Strength:</b> {$ir['strength']} [Ranked: {$ir['strank']}]</td>
<td><b>Agility:</b> {$ir['agility']} [Ranked: {$ir['agirank']}]</td>
</tr>
<tr>
<td><b>Guard:</b> {$ir['guard']} [Ranked: {$ir['guarank']}]</td>
<td><b>Labour:</b> {$ir['labour']} [Ranked: {$ir['labrank']}]</td>
</tr>
<tr>
<td><b>IQ: </b> {$ir['IQ']} [Ranked: {$ir['IQrank']}]</td>
<td><b>Total stats:</b> {$ts} [Ranked: $tsrank]</td>
</tr>
</table>
OUT;

print <<<OUT
<table cellspacing="1" border="1" cellpadding="3" class="table" width="70%">
<tr><td colspan="2"><b>Attack Statistics</b></td></tr>
<tr>
<td><b>Total Attacks:</b> {$r['atotal']}</td>
<td><b>Attacks Won:</b> {$r['awon']}</td>
</tr>
<tr>
<td><b>Attacks Lost: {$r['alost']}</td>
<td><b>Times Attacked: {$r['tattacked']}</td>
</tr>
<tr>
<td><b>People Left: {$r['pleft']}</td>
<td><b>People Hospilatized: {$r['phosp']}</td>
</tr>
<tr>
<td><b>People Mugged: {$r['pmugged']}</td>
<td><b>Money Mugged: \${$r['mmugged']}</td>
</tr>
</table>
OUT;

print "<h3>Bank</h3>";
if($ir['bankmoney']>-1)
{
switch($_GET['action'])
{
case "deposit":
deposit();
break;

case "withdraw":
withdraw();
break;

default:
<span class="highlight">index</span>();
break;
}

}
else
{
if(isset($_GET['buy']))
{
if($ir['money']>19999)
{
print "Congratulations, you bought a bank account for \$20,000!

<a href='index.php'>Start using my account</a>";
mysql_query("UPDATE users SET money=money-20000,bankmoney=0 WHERE userid=$userid",$c);
}
else
{
print "You do not have enough money to open an account.
<a href='index.php'>Back</a>";
}
}
else
{
print "Open a bank account today, just \$20,000!

<a href='index.php?buy'> Yes, sign me up!</a>";
}
}
function <span class="highlight">index</span>()
{
global $ir,$c,$userid,$h;
print "\n<b>You currently have \${$ir['bankmoney']} in the bank.</b>

At the end of each day, your bank balance will go up by 0.3%.

<table width='75%' border='2' bordercolor='#lime'> <tr> <td width='50%'><b>Deposit Money</b>

It will cost you 0% of the money you deposit, rounded up. The maximum fee is \$0.<form action='<span class="highlight">index</span>.php?action=deposit' method='post'>
Amount: <input type='text' name='deposit' value='{$ir['money']}' />

<input type='submit' value='Deposit' /></form></td> <td>
<b>Withdraw Money</b>

There is no fee on withdrawals.<form action='<span class="highlight">index</span>.php?action=withdraw' method='post'>
Amount: <input type='text' name='withdraw' value='{$ir['bankmoney']}' />

<input type='submit' value='Withdraw' /></form></td> </tr> </table>";
}
function deposit()
{
global $ir,$c,$userid,$h;
$_POST['deposit']=abs((int) $_POST['deposit']);
if($_POST['deposit'] > $ir['money'])
{
print "You do not have enough money to deposit this amount.";
}
else
{
$fee=ceil($_POST['deposit']*0/100);
if($fee > 0) { $fee=0; }
$gain=$_POST['deposit']-$fee;
$ir['bankmoney']+=$gain;
mysql_query("UPDATE users SET bankmoney=bankmoney+$gain, money=money-{$_POST['deposit']} where userid=$userid",$c);
print "You hand over \${$_POST['deposit']} to be deposited, 

after the fee is taken (\$$fee), \$$gain is added to your account. 

<b>You now have \${$ir['bankmoney']} in the bank.</b>

<a href='index.php'> Back</a>";
}
}
function withdraw()
{
global $ir,$c,$userid,$h;
$_POST['withdraw']=abs((int) $_POST['withdraw']);
if($_POST['withdraw'] > $ir['bankmoney'])
{
print "You do not have enough banked money to withdraw this amount.";
}
else
{

$gain=$_POST['withdraw'];
$ir['bankmoney']-=$gain;
mysql_query("UPDATE users SET bankmoney=bankmoney-$gain, money=money+$gain where userid=$userid",$c);
print "You ask to withdraw $gain, 

the banking lady grudgingly hands it over. 

<b>You now have \${$ir['bankmoney']} in the bank.</b>

<a href='index.php'> Back</a>";
}
}
$h->endpage();
?>

Take out the <span class="highlight"></span> from line 112

Link to comment
Share on other sites

seker line 141

needs to be

function index()

and

112 needs to be

index();

Ahhh Thank you, thank you. I literally stared at this for two hours last night. As I said, I'm just learning and learning as I go on top of that, so I had no clue.

 

Also, this shows up only on the index, now. It was there before I got this particular error, too, but I wasn't sure how to handle it.

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/drewsch1/public_html/test/global_func.phpon line 266

This is the line it's talking about:

 

                    $c);
   return mysql_result($q, 0, 0) + 1;
}

 

Is this a problem with something on Index.php or Global_func.php?

Link to comment
Share on other sites

no it just means on the file thats running it cannot understand where the function has come from so it always blame a file that asked for it..

This doesnt mean the resulting named file is the problem

 

loooking at your code it seems to be asking for index.php all the time whats the actual name of the file the script above belongs too ?

Edited by illusions
Link to comment
Share on other sites

no it just means on the file thats running it cannot understand where the function has come from so it always blame a file that asked for it..

This doesnt mean the resulting named file is the problem

Okay, got it. So there's something still out of whack on my Index.php. I'm assuming so, at least, since that's the only page displaying it.

The file referenced in the error is global_func.php and the original file I posted about is index.php.

Thank you guys so much for your help. Been a very positive first experience in the forums.

Link to comment
Share on other sites

try this one

 

<?php
$housequery=1;
session_start();
require "global_func.php";
if($_SESSION['loggedin']==0) { header("Location: login.php");exit; }
$userid=$_SESSION['userid'];
require "header.php";
$h = new headers;
$h->startheaders();
include "mysql.php";
global $c;
$is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error());
$ir=mysql_fetch_array($is);
check_level();
$fm=money_formatter($ir['money']);
$cm = money_formatter($ir['crystals'], '');
$lv=date('F j, Y, g:i a',$ir['laston']);
$h->userdata($ir,$lv,$fm,$cm);
$h->menuarea();
$exp=(int)($ir['exp']/$ir['exp_needed']*100);
$exp_n=(int)($ir['exp_needed']);


print <<<OUT
<table cellspacing="1" border="1" cellpadding="3" class="table" width="70%">
<tr><td colspan="2"><b>General Information</b></td></tr>
{$geninf}
<tr>
<td><b>Name:</b> {$ir['username']}</td>
<td><b>Crystals:</b> {$cm}</td>
</tr>
<tr>
<td><b>Level:</b> {$ir['level']}</td>
<td><b>Exp:</b> {$exp}%  ({$exp}/{$exp_n})</td>
</tr>
<tr>
<td><b>Money:</b> $fm</td>
<td><b>HP:</b> {$ir['hp']}/{$ir['maxhp']}</td>
</tr></br>
OUT;


$ts=$ir['strength']+$ir['agility']+$ir['guard']+$ir['labour']+$ir['IQ'];
$ir['strank']=get_rank($ir['strength'],'strength');
$ir['agirank']=get_rank($ir['agility'],'agility');
$ir['guarank']=get_rank($ir['guard'],'guard');
$ir['labrank']=get_rank($ir['labour'],'labour');
$ir['IQrank']=get_rank($ir['IQ'],'IQ');
$tsrank=get_rank($ts,'strength+agility+guard+labou  r+IQ');
$ir['strength']=number_format($ir['strength']);
$ir['agility']=number_format($ir['agility']);
$ir['guard']=number_format($ir['guard']);
$ir['labour']=number_format($ir['labour']);
$ir['IQ']=number_format($ir['IQ']);
$ts=number_format($ts);


print <<<OUT
<tr>
<td colspan="2"><b>Stats Info</b></td></tr>
<tr>
<td><b>Strength:</b> {$ir['strength']} [Ranked: {$ir['strank']}]</td>
<td><b>Agility:</b> {$ir['agility']} [Ranked: {$ir['agirank']}]</td>
</tr>
<tr>
<td><b>Guard:</b> {$ir['guard']} [Ranked: {$ir['guarank']}]</td>
<td><b>Labour:</b> {$ir['labour']} [Ranked: {$ir['labrank']}]</td>
</tr>
<tr>
<td><b>IQ: </b> {$ir['IQ']} [Ranked: {$ir['IQrank']}]</td>
<td><b>Total stats:</b> {$ts} [Ranked: $tsrank]</td>
</tr>
</table>
OUT;

print <<<OUT
<table cellspacing="1" border="1" cellpadding="3" class="table" width="70%">
<tr><td colspan="2"><b>Attack Statistics</b></td></tr>
<tr>
<td><b>Total Attacks:</b> {$r['atotal']}</td>
<td><b>Attacks Won:</b> {$r['awon']}</td>
</tr>
<tr>
<td><b>Attacks Lost: {$r['alost']}</td>
<td><b>Times Attacked: {$r['tattacked']}</td>
</tr>
<tr>
<td><b>People Left: {$r['pleft']}</td>
<td><b>People Hospilatized: {$r['phosp']}</td>
</tr>
<tr>
<td><b>People Mugged: {$r['pmugged']}</td>
<td><b>Money Mugged: \${$r['mmugged']}</td>
</tr>
</table>
OUT;

print "<h3>Bank</h3>";
if($ir['bankmoney']>-1)
{
switch($_GET['action'])
{
case "deposit":
deposit();
break;

case "withdraw":
withdraw();
break;

default:
index();
break;
}

}
else
{
if(isset($_GET['buy']))
{
if($ir['money']>19999)
{
print "Congratulations, you bought a bank account for \$20,000!

<a href='index.php'>Start using my account</a>";
mysql_query("UPDATE users SET money=money-20000,bankmoney=0 WHERE userid=$userid",$c);
}
else
{
print "You do not have enough money to open an account.
<a href='index.php'>Back</a>";
}
}
else
{
print "Open a bank account today, just \$20,000!

<a href='index.php?buy'> Yes, sign me up!</a>";
}
}
function index()
{
global $ir,$c,$userid,$h;
print "\n<b>You currently have \${$ir['bankmoney']} in the bank.</b>

At the end of each day, your bank balance will go up by 0.3%.

<table width='75%' border='2' bordercolor='#lime'> <tr> <td width='50%'><b>Deposit Money</b>

It will cost you 0% of the money you deposit, rounded up. The maximum fee is \$0.<form action='?action=deposit' method='post'>
Amount: <input type='text' name='deposit' value='{$ir['money']}' />

<input type='submit' value='Deposit' /></form></td> <td>
<b>Withdraw Money</b>

There is no fee on withdrawals.<form action='?action=withdraw' method='post'>
Amount: <input type='text' name='withdraw' value='{$ir['bankmoney']}' />

<input type='submit' value='Withdraw' /></form></td> </tr> </table>";
}
function deposit()
{
global $ir,$c,$userid,$h;
$_POST['deposit']=abs((int) $_POST['deposit']);
if($_POST['deposit'] > $ir['money'])
{
print "You do not have enough money to deposit this amount.";
}
else
{
$fee=ceil($_POST['deposit']*0/100);
if($fee > 0) { $fee=0; }
$gain=$_POST['deposit']-$fee;
$ir['bankmoney']+=$gain;
mysql_query("UPDATE users SET bankmoney=bankmoney+$gain, money=money-{$_POST['deposit']} where userid=$userid",$c);
print "You hand over \${$_POST['deposit']} to be deposited, 

after the fee is taken (\$$fee), \$$gain is added to your account. 

<b>You now have \${$ir['bankmoney']} in the bank.</b>

<a href='index.php'> Back</a>";
}
}
function withdraw()
{
global $ir,$c,$userid,$h;
$_POST['withdraw']=abs((int) $_POST['withdraw']);
if($_POST['withdraw'] > $ir['bankmoney'])
{
print "You do not have enough banked money to withdraw this amount.";
}
else
{

$gain=$_POST['withdraw'];
$ir['bankmoney']-=$gain;
mysql_query("UPDATE users SET bankmoney=bankmoney-$gain, money=money+$gain where userid=$userid",$c);
print "You ask to withdraw $gain, 

the banking lady grudgingly hands it over. 

<b>You now have \${$ir['bankmoney']} in the bank.</b>

<a href='index.php'> Back</a>";
}
}
$h->endpage();
?>

 

see if that works

Link to comment
Share on other sites

the problem is you have

<span class="highlight">index</span>

inside your forms

example

There is no fee on withdrawals.<form action='<span class="highlight">index</span>.php?action=withdraw' method='post'>

Amount: <input type='text' name='withdraw' value='{$ir['bankmoney']}' />

This may be due to a copy and paste from an exsisting code MWG

Link to comment
Share on other sites

try this one

 

<?php
$housequery=1;
session_start();
require "global_func.php";
if($_SESSION['loggedin']==0) { header("Location: login.php");exit; }
$userid=$_SESSION['userid'];
require "header.php";
$h = new headers;
$h->startheaders();
include "mysql.php";
global $c;
$is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error());
$ir=mysql_fetch_array($is);
check_level();
$fm=money_formatter($ir['money']);
$cm = money_formatter($ir['crystals'], '');
$lv=date('F j, Y, g:i a',$ir['laston']);
$h->userdata($ir,$lv,$fm,$cm);
$h->menuarea();
$exp=(int)($ir['exp']/$ir['exp_needed']*100);
$exp_n=(int)($ir['exp_needed']);


print <<<OUT
<table cellspacing="1" border="1" cellpadding="3" class="table" width="70%">
<tr><td colspan="2"><b>General Information</b></td></tr>
{$geninf}
<tr>
<td><b>Name:</b> {$ir['username']}</td>
<td><b>Crystals:</b> {$cm}</td>
</tr>
<tr>
<td><b>Level:</b> {$ir['level']}</td>
<td><b>Exp:</b> {$exp}%  ({$exp}/{$exp_n})</td>
</tr>
<tr>
<td><b>Money:</b> $fm</td>
<td><b>HP:</b> {$ir['hp']}/{$ir['maxhp']}</td>
</tr></br>
OUT;


$ts=$ir['strength']+$ir['agility']+$ir['guard']+$ir['labour']+$ir['IQ'];
$ir['strank']=get_rank($ir['strength'],'strength');
$ir['agirank']=get_rank($ir['agility'],'agility');
$ir['guarank']=get_rank($ir['guard'],'guard');
$ir['labrank']=get_rank($ir['labour'],'labour');
$ir['IQrank']=get_rank($ir['IQ'],'IQ');
$tsrank=get_rank($ts,'strength+agility+guard+labou  r+IQ');
$ir['strength']=number_format($ir['strength']);
$ir['agility']=number_format($ir['agility']);
$ir['guard']=number_format($ir['guard']);
$ir['labour']=number_format($ir['labour']);
$ir['IQ']=number_format($ir['IQ']);
$ts=number_format($ts);


print <<<OUT
<tr>
<td colspan="2"><b>Stats Info</b></td></tr>
<tr>
<td><b>Strength:</b> {$ir['strength']} [Ranked: {$ir['strank']}]</td>
<td><b>Agility:</b> {$ir['agility']} [Ranked: {$ir['agirank']}]</td>
</tr>
<tr>
<td><b>Guard:</b> {$ir['guard']} [Ranked: {$ir['guarank']}]</td>
<td><b>Labour:</b> {$ir['labour']} [Ranked: {$ir['labrank']}]</td>
</tr>
<tr>
<td><b>IQ: </b> {$ir['IQ']} [Ranked: {$ir['IQrank']}]</td>
<td><b>Total stats:</b> {$ts} [Ranked: $tsrank]</td>
</tr>
</table>
OUT;

print <<<OUT
<table cellspacing="1" border="1" cellpadding="3" class="table" width="70%">
<tr><td colspan="2"><b>Attack Statistics</b></td></tr>
<tr>
<td><b>Total Attacks:</b> {$r['atotal']}</td>
<td><b>Attacks Won:</b> {$r['awon']}</td>
</tr>
<tr>
<td><b>Attacks Lost: {$r['alost']}</td>
<td><b>Times Attacked: {$r['tattacked']}</td>
</tr>
<tr>
<td><b>People Left: {$r['pleft']}</td>
<td><b>People Hospilatized: {$r['phosp']}</td>
</tr>
<tr>
<td><b>People Mugged: {$r['pmugged']}</td>
<td><b>Money Mugged: \${$r['mmugged']}</td>
</tr>
</table>
OUT;

print "<h3>Bank</h3>";
if($ir['bankmoney']>-1)
{
switch($_GET['action'])
{
case "deposit":
deposit();
break;

case "withdraw":
withdraw();
break;

default:
index();
break;
}

}
else
{
if(isset($_GET['buy']))
{
if($ir['money']>19999)
{
print "Congratulations, you bought a bank account for \$20,000!

<a href='index.php'>Start using my account</a>";
mysql_query("UPDATE users SET money=money-20000,bankmoney=0 WHERE userid=$userid",$c);
}
else
{
print "You do not have enough money to open an account.
<a href='index.php'>Back</a>";
}
}
else
{
print "Open a bank account today, just \$20,000!

<a href='index.php?buy'> Yes, sign me up!</a>";
}
}
function index()
{
global $ir,$c,$userid,$h;
print "\n<b>You currently have \${$ir['bankmoney']} in the bank.</b>

At the end of each day, your bank balance will go up by 0.3%.

<table width='75%' border='2' bordercolor='#lime'> <tr> <td width='50%'><b>Deposit Money</b>

It will cost you 0% of the money you deposit, rounded up. The maximum fee is \$0.<form action='?action=deposit' method='post'>
Amount: <input type='text' name='deposit' value='{$ir['money']}' />

<input type='submit' value='Deposit' /></form></td> <td>
<b>Withdraw Money</b>

There is no fee on withdrawals.<form action='?action=withdraw' method='post'>
Amount: <input type='text' name='withdraw' value='{$ir['bankmoney']}' />

<input type='submit' value='Withdraw' /></form></td> </tr> </table>";
}
function deposit()
{
global $ir,$c,$userid,$h;
$_POST['deposit']=abs((int) $_POST['deposit']);
if($_POST['deposit'] > $ir['money'])
{
print "You do not have enough money to deposit this amount.";
}
else
{
$fee=ceil($_POST['deposit']*0/100);
if($fee > 0) { $fee=0; }
$gain=$_POST['deposit']-$fee;
$ir['bankmoney']+=$gain;
mysql_query("UPDATE users SET bankmoney=bankmoney+$gain, money=money-{$_POST['deposit']} where userid=$userid",$c);
print "You hand over \${$_POST['deposit']} to be deposited, 

after the fee is taken (\$$fee), \$$gain is added to your account. 

<b>You now have \${$ir['bankmoney']} in the bank.</b>

<a href='index.php'> Back</a>";
}
}
function withdraw()
{
global $ir,$c,$userid,$h;
$_POST['withdraw']=abs((int) $_POST['withdraw']);
if($_POST['withdraw'] > $ir['bankmoney'])
{
print "You do not have enough banked money to withdraw this amount.";
}
else
{

$gain=$_POST['withdraw'];
$ir['bankmoney']-=$gain;
mysql_query("UPDATE users SET bankmoney=bankmoney-$gain, money=money+$gain where userid=$userid",$c);
print "You ask to withdraw $gain, 

the banking lady grudgingly hands it over. 

<b>You now have \${$ir['bankmoney']} in the bank.</b>

<a href='index.php'> Back</a>";
}
}
$h->endpage();
?>

 

see if that works

Same mysql warning on the home page.

I'm wondering. I thought I cleverly figured out how to display actual exp. needed next to the percentage by adding a function to the top of that page. Should it go in global_func.php somewhere, instead? And just reference it from index.php?

i.e. Should I move

$exp_n=(int)($ir['exp_needed']);

to global_func.php?

And just call it like I did here:

({$exp}/{$exp_n})

on index.php?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...