oni-kun Posted December 23, 2009 Share Posted December 23, 2009 I have a table set where the rows are in this format: ID - Done - Length - Weight And there are 43 rows.. but if I wanted to update a row (from a mass of inputs) for ($i = 0; $i <=42; $i++) { $sql = " UPDATE `personal` SET done='".mysql_real_escape_string(Checkboxfilter($_POST['done'], "$i"))."', //returns yes/no length='".mysql_real_escape_string($_POST['len'][$i])."', weight='".mysql_real_escape_string($_POST['weight'][$i])."', WHERE id='".$i."' "; mysql_query($sql) or die('MYSQL Erorr:' . mysql_error()); } It gives me this error: MYSQL Erorr: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 'WHERE id='0'' at line 5 Is there a problem with using WHERE id=$id in the update command? Quote Link to comment https://forums.phpfreaks.com/topic/186148-using-_post-with-update-query-think-its-easy/ Share on other sites More sharing options...
ChemicalBliss Posted December 23, 2009 Share Posted December 23, 2009 you have one too many commas If you ever get MySQL Syntax errors, Echo/Print the query and make sure it is what you expect . -CB- Quote Link to comment https://forums.phpfreaks.com/topic/186148-using-_post-with-update-query-think-its-easy/#findComment-983049 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.