What happens is when you "buy" an item it inserts it into the DB, but instead of ADDING it, it OVERWRITES, here's an example:
Let's say the "item" you had before was id 1. Then you bought another "item" that was id 2.
It looks like this first: Array,1
Now it looks like this: Array,2
I was thinking it shoudl look like this: Array,1,2
CODE:
<?
//connect to mysql database
mysql_connect("localhost","*****","******");
mysql_select_db("wizardduels_com");
//do some querys
mysql_query("update users set chips=chips-".$price." where user='".$user."'");
$strinv = mysql_query("select * from stores where id='".$storeid."'");
$usrinv = mysql_query("select * from users where user='".$user."'");
$inv = mysql_fetch_assoc($strinv);
$itm = mysql_fetch_assoc($usrinv);
$inve = preg_split("/,/",$inv);
$item = preg_split("/,/",$itm);
//remove the item from the store
if($storid < 50) {
$i = 0;
foreach($inve as $cur) {
if($cur != $itemid) {
$spaz[$i] = $cur;
}
$i++;
}
$valtoinsert = join(",",$spaz);
mysql_query("update stores where id='".$storid."' set items='".$valtoinsert."'");
}
//give item to the user
array_push($item, $itemid);
$othervaluetoinsert = join(",",$item);
mysql_query("update users set items='".$othervaluetoinsert."' where user='".$user."'");
echo "You have successfully bought the item.<br>";
echo "<a href=\"stores.php?user=".$user."&pass=".$pass."\">back</a>";
?>