I'm getting the message that it's unable to add to my backpack when I purchase an item. Here's me code:
Code: Select all
<?php
session_start();
include("header.php");
if(!isset($_SESSION['uid'])){
$id=$_SESSION['id'];
echo "You must be logged in to view this page!";
}else{
$randid=$_GET['randid'];
?>
<div id="table">
<?php
$id = $user['id'];
$iteminfo="SELECT * from store where randid='$randid'";
$iteminfo2=mysql_query($iteminfo) or die("could not get item stats!");
$iteminfo3=mysql_fetch_array($iteminfo2);
if ($stats['gold'] < $iteminfo3['price'])
{
echo "You do not have enough Gold for this purchase!";
echo "<center><a href='index.php'>Go Back</center>";
exit;
}
$name = $iteminfo3['name'];
$stats1 = $iteminfo3['stats'];
$statadd = $iteminfo3['statadd'];
$type = $iteminfo3['type'];
$randid2 = rand(1000,999999999);
$itembought = "INSERT into inventory(id, name, stats, statadd, randid,type) VALUES ('$id','$name','$stats1','$statadd','$randid2','$type')";
mysql_query($itembought) or die("could not insert item into backpack");
$updateplayer="update stats set gold=gold-'$iteminfo3[price]' where id='$id'";
mysql_query($updateplayer) or die("Could not update player");
echo $name . " Purchased";
echo "<center><a href='index.php'>Go Back</center>";
////did not make a - counter for item////
}
?>
</div>