refiking Posted August 24, 2007 Share Posted August 24, 2007 Where is the error? mysql_query("INSERT INTO list (status) VALUES ('$status') WHERE name = $name")or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/66559-solved-sql-syntax-error/ Share on other sites More sharing options...
lemmin Posted August 24, 2007 Share Posted August 24, 2007 Probably needs to be name = '$name'. Note the apostrophes. Quote Link to comment https://forums.phpfreaks.com/topic/66559-solved-sql-syntax-error/#findComment-333374 Share on other sites More sharing options...
refiking Posted August 24, 2007 Author Share Posted August 24, 2007 Changed that and it still says the same thing. What else could it be? Quote Link to comment https://forums.phpfreaks.com/topic/66559-solved-sql-syntax-error/#findComment-333376 Share on other sites More sharing options...
lemmin Posted August 24, 2007 Share Posted August 24, 2007 Could you post what the error output is? Quote Link to comment https://forums.phpfreaks.com/topic/66559-solved-sql-syntax-error/#findComment-333379 Share on other sites More sharing options...
refiking Posted August 24, 2007 Author Share Posted August 24, 2007 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 name = 'John' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/66559-solved-sql-syntax-error/#findComment-333382 Share on other sites More sharing options...
lemmin Posted August 24, 2007 Share Posted August 24, 2007 Oh. INSERT INTO adds a new row. You can't add a new row to a row that matches criteria. Are you trying to add a new row or change data in a current row? If you are adding a new row, just remove the where clause, otherwise you should be using UPDATE instead. http://dev.mysql.com/doc/refman/5.1/en/update.html Quote Link to comment https://forums.phpfreaks.com/topic/66559-solved-sql-syntax-error/#findComment-333386 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.