callesson Posted March 25, 2010 Share Posted March 25, 2010 Hey guys! I'm having this code were you buy one potion and it will end up in your inventory, also you will loose some money. When you buy your first potion it will go to Slot1, and sec potion will go to Slot2 and third to Slot3. And when its full (there is only three slots) you will go to inventoryisfull.php. My problems is that when i have Full1=1, Full2=2 and Full3=0 it wont add the potion to Slot3 instead it adds it to Slot2. And also if now Slot2 = false, like (if(1+1=3) update slot2... then my buy.php page will go blank like if there was an error with Slot3 or something Database, Colums user Slot1 Slot2 Slot3 Full1 Full2 Full3 Php, Code (buy.php) [code=php:0] <?php session_start(); xxxx include ('connect.php'); if($_POST['flaska']) { $Potion = $_POST['Potion']; $query = mysql_query("SELECT * FROM inventory WHERE user='$_SESSION[user]'"); while($row = mysql_fetch_array($query)) $Full1 = $row['Full1']; $Full2 = $row['Full2']; $Full3 = $row['Full3']; $sql="SELECT * FROM inventory WHERE user='$_SESSION[user]'"; $result=mysql_query($sql); $count=mysql_num_rows($result); if($count==0) { $insert=mysql_query("INSERT INTO inventory (user,Slot1,Slot2,Slot3,Full1,Full2,Full3) VALUES ('$_SESSION[user]','$Potion','Nothing','Nothing','1','0','0')"); $update=mysql_query("UPDATE character SET Gold=Gold -33 WHERE User='$_SESSION[user]'"); header("Location:chardone.php"); } if($count==1 && $Full1 == 0 && $Full2 !=2 && $Full3 != 3) { $update1=mysql_query("UPDATE inventory SET Slot1='$Potion', Full1=1 WHERE user='$_SESSION[user]'"); $update2=mysql_query("UPDATE chars SET Gold=Gold -33 WHERE User='$_SESSION[user]'"); header("Location:chardone.php"); } if($count==1 && $Full1 == 1 && $Full2==0) { $update3=mysql_query("UPDATE inventory SET Slot2='$Potion', Full2=2 WHERE user='$_SESSION[user]'"); $update4=mysql_query("UPDATE chars SET Gold=Gold -33 WHERE User='$_SESSION[user]'"); header("Location:chardone.php"); } if($count==1 && $Full1 == 1 && $Full2==2 && $Full3==0) { $update5=mysql_query("UPDATE inventory SET Slot3='$Potion', Full3=3 WHERE user='$_SESSION[user]'"); $update6=mysql_query("UPDATE chars SET Gold=Gold -33 WHERE User='$_SESSION[user]'"); header("Location:chardone.php"); } if($count==1 && $Full1 == 1 && $Full2==2 && $Full3==3) { header("Location:inventoryfull.php"); } } ?> [/code] Link to comment https://forums.phpfreaks.com/topic/196470-truble-with-my-buy-code/ Share on other sites More sharing options...
callesson Posted March 25, 2010 Author Share Posted March 25, 2010 Anyone that can explain plz? Link to comment https://forums.phpfreaks.com/topic/196470-truble-with-my-buy-code/#findComment-1031603 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.