It detects if the form submit button "Buy" is the button being clicked
it sets a variable idw to the value of the weapon dropdown box (not working)
it checks if the gold you have is enough to purchase the weapon "$weaponprices[$idw]"
if you have enough gold it,
then (inv is the inventory) counts to the end of my array "inventory" "$x = count($inv)-1"
subtracts the gold from your current gold and adds the weapon to your inventory
"$inv[$x]=$stweaponlist[$idw];"
else
it displays "You do not have enough gold to purchase blah item"
The errors:
Notice: Undefined index: weapon in c:\program files\easyphp1-8\www\mythic aeons\bankdep.php on line 167
Notice: Undefined index: in c:\program files\easyphp1-8\www\mythic aeons\bankdep.php on line 169
Notice: Undefined index: in c:\program files\easyphp1-8\www\mythic aeons\bankdep.php on line 172
Notice: Undefined variable: stweaponlist in c:\program files\easyphp1-8\www\mythic aeons\bankdep.php on line 173
heres the code
(Note you'll see the //problem starts here below part, although some of the arrays used are up the top (inv is in my database)
Code: Select all
<html>
<head>
<style type='text/css'>
body
{
background-image:
url('SilverBG.jpg')
}
</style>
</head>
<body>
<?php
$id=$_SESSION['id'];
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("chars", $con);
$result = mysql_query("SELECT * FROM chars
WHERE idcount = $id");
$row = mysql_fetch_array($result);
$horz=$row['horz'];
$vert=$row['vert'];
$currtown=$row['currtown'];
$gold=$row['gold'];
$bank=$row['bankedgold'];
$currtownwe=$currtown;
$dse=$row['dse'];
$egerr=false;
$egerr2=false;
$weapon=$row['weapon'];
if (isset($_POST['De1']))
{
if ($_POST['De1'] == 'De2')
{
$eg=$_POST['Bankopt2'];
if ($eg < 0)
{
if ($gold + $eg >= 0)
{
$bank=$bank-$eg;
$gold=$gold+$eg;
$eg2=substr($eg, 1,strlen($eg));
echo '<div style="position: absolute; top: 360; left: 400;"><table border=\'3\' width="325"> <tr> <td align="center"><b>You have deposited '.$eg2. ' gold into your bank</b></td></tr></table></div>';
}
else
{
echo '<div style="position: absolute; top: 360; left: 400;"><table border="3" width="325"> <tr> <td align="center"><b>You do not have that much current gold</b></td></tr></table></div>';
}
}
if ($eg > 0)
{
if ($eg <= $bank)
{
echo '<div style="position: absolute; top: 360; left: 400;"><table border=\'3\' width="325"> <tr> <td align="center"><b>You have withdrawn '.$eg. ' gold from your bank</b></td></tr></table></div>';
$bank=$bank-$eg;
$gold=$gold+$eg;
}
else
{
echo '<div style="position: absolute; top: 360; left: 400;"><table border="3" width="325"> <tr> <td align="center"><b>You do not have that much gold in your bank</b></td></tr></table></div>';
}
}
}
}
if ($horz == 4 && $vert == 0)
{
if ($currtown == "Harkan")
{
$dse=false;
?>
<div style='position: absolute; top:295; left:427;'>
<?php
echo '<i>'.$currtownwe.' </i>Bank <br /> Use a normal value to withdraw, negative to deposit';
?>
</div>
<!--<div style='position: absolute; top: 300; left: 425;'>
<form method="post" action="Harkan.php">
<input type="text" name='Bankopt1'>
<input type='hidden' name='With1' value='With2'>
<input type="submit" value="Withdraw">
</form>
</div>-->
<div style='position: absolute; top: 335; left: 425;'>
<form method="post" action="Harkan.php">
<input type="text" name='Bankopt2'>
<input type='hidden' name='De1' value='De2'>
<input type="submit" value="Withdraw/Deposit">
</form>
</div>
<?php
}
}
if ($dse==true)
{
mysql_query("UPDATE chars SET dse = 1 WHERE idcount = $id")or die ("bankdep1 ".mysql_error());
}
else
{
mysql_query("UPDATE chars SET dse = 0 WHERE idcount = $id")or die ("bankdep4 ".mysql_error());
}
mysql_query("UPDATE chars SET gold = $gold WHERE idcount=$id")or die ("bankdep2 ".mysql_error());
mysql_query("UPDATE chars SET bankedgold = $bank WHERE idcount=$id")or die ("bankdep3 ".mysql_error());
//////////////////////////////////////////PROBLEM BELOW
if ($horz == 2 && $vert == 2)
{
if ($currtownwe == "Harkan")
{
$dse=true;
?>
<div style='position: absolute; top: 200; left: 400;'>
<table border="3">
<tr>
<td align="center">
<b>Weapon shop</b>
</td>
</tr>
<td align="left">
<form method="post" action="Harkan.php">
<select name="weapon">;
<option value=0>Iron Dagger, Price: 36g</option>
<option value=1>Iron Sword, Price: 89g</option>
<option value=2>Steel Sword, Price: 201g</option>
<option value=3>Titan Sword, Price: 745g</option>
</select></form>
</td>
</tr>
</table>
</div>
<div style="position: absolute; top: 280; left: 445;">
<form method="post" action="Harkan.php">
<input type='hidden' name='req1' value='req2'>
<input type="submit" value="Requirements">
</form>
</div>
<div style="position: absolute; top: 280; left: 400;">
<form method="post" action="Harkan.php">
<input type='hidden' name='Buy1' value='Buy2'>
<input type="submit" value="Buy">
</form>
</div>
<?php
}
}
else
{
$dse=true;
}
if (isset($_POST['Buy1']))
{
if ($_POST['Buy1'] == 'Buy2')
{
$idw=$_POST['weapon']; //line 167
if ($gold >= $weaponprices[$idw]) //line 169
{
$x = count($inv)-1;
$gold=$gold-$weaponprices[$idw]; //line 172
$inv[$x]=$stweaponlist[$idw]; // line 173
}
else
{
echo 'You do not have enough gold to buy '.$stweaponlist[$idw];
}
}
}
//PROB ABOVE
?>
</body>
</html>so can anyone tell me my mistakes I dont exactly get why its not working:P
Thanks in advance
- sorry just realized had no php tags:P