scmeeker Posted July 6, 2010 Share Posted July 6, 2010 The following code is from the form action code. On my site, a user adds a new item, then goes to the next page to confirm the details with the option to edit and update their information. The problem is, its not updating the information in the database. The information is showing up in the form fine and referring to the correct item id but just not updating. mysql_connect("localhost", "", "", "") or die(mysql_error()); mysql_select_db("store") or die(mysql_error()); $item_title = mysql_real_escape_string($_POST[title]); $item_description = mysql_real_escape_string($_POST[description]); $item_price = mysql_real_escape_string($_POST[price]); $item_location = mysql_real_escape_string($_POST[location]); $item_ship_to = mysql_real_escape_string($_POST[ship_to]); $item_shipping_cost = mysql_real_escape_string($_POST[shipping_cost]); $item_international = mysql_real_escape_string($_POST[international]); $item_in_shipping = mysql_real_escape_string($_POST[in_shipping]); $item_id = mysql_real_escape_string($_POST[id]); $username = $_SESSION['username']; $sql="UPDATE product SET title='$item_title', description='$item_description', price='$item_price', location='$item_location', ship_to='$item_ship_to', shipping_cost='$item_shipping_cost', international='$item_international', in_shipping='$item_in_shipping' WHERE id = [$item_id]"; header("location:add_new_product3.php?id={$item_id}=username=".$_SESSION['username'].""); if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } Any suggestions?? I've been really stuck on this! Thanks! Link to comment https://forums.phpfreaks.com/topic/206915-update-problems/ Share on other sites More sharing options...
premiso Posted July 6, 2010 Share Posted July 6, 2010 Because you are redirecting the page before it has a chance to run the mysql query? if (!mysql_query($sql)) { die('Error: ' . mysql_error()); }else { header("location:add_new_product3.php?id={$item_id}=username=".$_SESSION['username'].""); } Should do the trick. Link to comment https://forums.phpfreaks.com/topic/206915-update-problems/#findComment-1082047 Share on other sites More sharing options...
scmeeker Posted July 6, 2010 Author Share Posted July 6, 2010 Worked great! Thanks! Link to comment https://forums.phpfreaks.com/topic/206915-update-problems/#findComment-1082095 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.