inventoryID (this is key) inventoryitemID inventoryuserID inventoryquantity <? include('sidebar.php'); if($_SESSION[loggedin]) { Print "logged in and <br>"; $insert= "INSERT INTO inventory (inventoryitemID, inventoryuserID, inventoryquantity)VALUES('1', '$id', '2')" or die(mysql_error()); if(mysql_query($insert)) { print "worked and id is <br><br><br> $id"; } else{ print "nope"; } } ?> PHP: prints $id and the else. i have no idea why it wont insert O_O code seems ok..
Add a Line Print $insert; and run the value of $insert through phpmyadmin. Does it insert a row through phpmyadmin?
print is INSERT INTO inventory (inventoryitemID, inventoryuserID, inventoryquantity)VALUES('1', '1', '2') ID 1 is me = ) i am using phpmyadmin, It is a cpanel account. there is no error, im connected. im too tired to deal with this now. its annoying the crap out of me
So when you used phpMyAdmin, it worked? Also, these 2 lines: $insert= "INSERT INTO inventory (inventoryitemID, inventoryuserID, inventoryquantity)VALUES('1', '$id', '2')" or die(mysql_error()); if(mysql_query($insert)) PHP: should be: $insert= "INSERT INTO inventory (inventoryitemID, inventoryuserID, inventoryquantity)VALUES('1', '$id', '2')"; mysql_query($insert) or die(mysql_error()); echo 'success'; PHP:
personally, when i'm debugging or trying to find a problem i find it helpful to do: $insert= "INSERT INTO inventory (inventoryitemID, inventoryuserID, inventoryquantity)VALUES('1', '$id', '2')"; mysql_query($insert) or die($insert . '<br><br>' . mysql_error()); echo 'success'; PHP: makes it nice and easy to read the actual SQL and see if I can figure out exactly where the error is sometimes the error alone just isn't enough!