For some odd reason when i type i want to buy a certain amount it wont let me it keeps saying no such item go back to store, can anyone tell me if something is wrong with my code please
Thanks
Kamakasi
<?php $title = "Shop"; include("header.php"); ?>
<?php
print" <center>
<BR><B>Total Cash:</b> <font color=red>$stat[credits]</font> <br><BR>
";
?>
<?php
$whattodo = $_GET['whattodo'];
if ($whattodo=='buy') {
if(!$_GET[quantity]){
print "<P>Error: please enter a quantity.";
exit;
}
if($_GET[quantity]<=0){
print "<P>Quantity cannot be 0!";
exit;
}
$q = "select * from equipment where id='$wepid'";
$rs = mysql_query($q) or die('Error with query: ' . $q . '<br />' . mysql_error());
$arm = mysql_num_rows($rs);
if (empty ($wepid[id])) {
print "No such item Go back to the <a href=shop.php>shop</a>.";
include("footer.php");
exit;
}
$quant=$wepid[power]*$_GET[quantity];
$cost=$wepid[cost]*$_GET[quantity];
if ($cost > $stat[credits]) {
print "You can't afford that! Go back to the <a href=shop.php>shop</a>.";
include("footer.php");
exit;
}
print "<p>Item purchaced</b>.";
$quant=$wep[power]*$_GET[quantity];
$cost=$wep[cost]*$_GET[quantity];
mysql_query("update players set credits=credits-$cost where user='$stat[id]'");
mysql_query("update players set power='power'+'quantity' where id='$stat[id]'");
//mysql_query("update tribes set totalpower=totalpower+'$quant' where //id='$stat[tribe]'");
/////////////////////////////
//Add to ITEM NUMBER///
/////////////////////////////
$q = "select * from shop_ where item_id='$id'";
$rs = mysql_query($q) or die('Error with query: ' . $q . '<br />' . mysql_error());
$shop2 = mysql_num_rows($rs);
if($shop2==NULL){
mysql_query("INSERT INTO `shop_` ( `id` , `item_id`, `number` ) VALUES ('$stat[id]', '$_GET[id]', '0')");
mysql_query("update shop_ set number=number+'$quantity' where id='$stat[id]' and item_id='$id'");
}else{
mysql_query("update shop_ set number=number+'$quantity' where id='$stat[id]' and item_id='$id'");
}
////////////////////////////////////////////////////////////
//End of that. tehehe, that was simple enough. ;)///
///////////////////////////////////////////////////////////
}
?>
<?php
//////////////////////////////////////////////////////////////////////////////////////
// Now, lets do a live update of when these items where bought ;) mhm.///
/////////////////////////////////////////////////////////////////////////////////////
$q = "select * from players where id='$id'";
$rs = mysql_query($q) or die('Error with query: ' . $q . '<br />' . mysql_error());
$stat = mysql_num_rows($rs);
////////////////////////////////////////////////////////////////////////////
// Now, moving onto the what will happen if you buy an item./////
///////////////////////////////////////////////////////////////////////////
if (!$buy) {
print "The Shop.<br><br><table>";
print " <table>
<tr cellpadding=\"1\" cellspacing=\"1\"><td width=130><b><u>Name</td><td width=150><b><u>Effect</td><td width=150><b><u>Cost</td><td><b><u>Quantity</td></tr></table>";
$wep = mysql_query("select * from equipment order by cost asc");
while ($wsel = mysql_fetch_array($wep)) {
$cost=($wsel[cost]);
$atk=($wsel[power]);
$wpn=($wsel[name]);
print " <table>
<tr cellpadding=\"0\" cellspacing=\"0\"><td width=175>$wpn</td><td width=150>$atk</td><td width=150>$cost</td><td>
<form method=get action='?'>
<input type=text name=quantity size=5 >
<input type='hidden' name='whattodo' value='buy'>
<input type='hidden' name='id' value='$wep[id]'>
</td>
<td><input type=submit value=Buy></form>
</td></tr></table> ";
}
}
?>
<?php include("footer.php"); ?>