bradynorman Posted August 12, 2008 Share Posted August 12, 2008 Hi, I am using the following code; mysql_select_db($database_grcdb, $grcdb); foreach($id as $val) { $val2=$_POST['bin']; $query = "UPDATE stock SET status = 'warehouse' SET bin = '$val2' WHERE id = '$val'"; mysql_query($query) or die(mysql_error()); } mysql_close(); $updateGoTo = "stock.php"; header(sprintf("Location: %s", $updateGoTo)); the error i get is ; You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET bin = 'Array' WHERE id = '6'' at line 1 the form is submitted with to variables id[] and bin[] What am i doing wrong so that the $bin is not updated each time the loop runs? cheers Mike Link to comment https://forums.phpfreaks.com/topic/119322-arrays/ Share on other sites More sharing options...
DarkWater Posted August 12, 2008 Share Posted August 12, 2008 $bin is an array, and you can't put an array into a string. You need to loop it. Link to comment https://forums.phpfreaks.com/topic/119322-arrays/#findComment-614661 Share on other sites More sharing options...
akitchin Posted August 12, 2008 Share Posted August 12, 2008 i am locking this thread. please do not double-post; bump your other topic if absolutely necessary. you've received a reply in the other thread. Link to comment https://forums.phpfreaks.com/topic/119322-arrays/#findComment-614676 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.