zelig Posted April 12, 2012 Share Posted April 12, 2012 Okay, the function appears to work just fine, except it doesn't add to the database. I don't have any errors, so I'm not quite sure what is going on. I've got an echo on the $id and $item_id, and both were pulling correctly. Just not being added to the table `sale`... Anyone help? Thanks in advance! function addshopinv($id) { error_reporting(E_ALL); ini_set('display_errors', 1); if (isset($_POST["submit"])) { extract($_POST); $errors = 0; $errorlist = ""; if ($name == "") { $errors++; $errorlist .= "Name is required.<br />"; } else if ($errors == 0) { $dbh=dbconnect() or die ("Userlist read error: " . mysql_error()."<br>"); mysql_select_db("XXX"); $query = mysql_query("SELECT id FROM items WHERE name='$name'"); while ($result = mysql_fetch_array($query)){ $item_id = $result['id']; echo $id; $query1 = mysql_query("INSERT INTO sale SET shop_id='$id', item_id='$item_id"); } admindisplay("Inventory Item Added.","Add New Inventory Item"); } else { admindisplay("<b>Errors:</b><br /><div style=\"color:red;\">$errorlist</div><br />Please go back and try again.", "Add New Item to Shop"); } } Quote Link to comment https://forums.phpfreaks.com/topic/260807-cant-figure-out-why-it-wont-add-to-the-database/ Share on other sites More sharing options...
zelig Posted April 12, 2012 Author Share Posted April 12, 2012 I found it... *headsdesk* Quote Link to comment https://forums.phpfreaks.com/topic/260807-cant-figure-out-why-it-wont-add-to-the-database/#findComment-1336701 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.