iPixel Posted September 9, 2009 Share Posted September 9, 2009 It's a simple POST from a dynamic form to a page that collects them. type sent as <input... name="type[]" id="type[]"> All the data goes through and is collected no problem, but my bloody sql query craps out and i do not see a reason why. Here's the query. <?php $query = "UPDATE tablename SET type = '$type[$x]', price = '$price[$x]', desc = '$desc[$x]', link = '$link[$x]' WHERE id = '$id[$x]'"; ?> Here is the error: 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 'desc = 'descriptions for the purchase item' at line 1 Thanks For the help! Link to comment https://forums.phpfreaks.com/topic/173651-solved-whats-wrong-with-my-query/ Share on other sites More sharing options...
Bricktop Posted September 9, 2009 Share Posted September 9, 2009 Hi iPixel, 'desc' is a MySQL reserved word. You can use it but you will need to escape it with backticks `. See http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html for more information. So your code needs to read: <?php $query = "UPDATE tablename SET type = '$type[$x]', price = '$price[$x]', `desc` = '$desc[$x]', link = '$link[$x]' WHERE id = '$id[$x]'"; ?> Link to comment https://forums.phpfreaks.com/topic/173651-solved-whats-wrong-with-my-query/#findComment-915358 Share on other sites More sharing options...
iPixel Posted September 9, 2009 Author Share Posted September 9, 2009 Ok i feel like a chump, i actually knew that but it completely kept missing me lol. TY! Link to comment https://forums.phpfreaks.com/topic/173651-solved-whats-wrong-with-my-query/#findComment-915364 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.