doforumda Posted October 16, 2009 Share Posted October 16, 2009 i am using this insert query $query = "INSERT into cv(quiz) values('".$score."') WHERE id='".$lastId."'" or die(mysql_error()); but this is not working it displays this 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 'WHERE id=25' at line 1 how to remove this error Link to comment https://forums.phpfreaks.com/topic/177914-how-to-use-insert-query/ Share on other sites More sharing options...
dymon Posted October 16, 2009 Share Posted October 16, 2009 You should not use WHERE in an INSERT statement. Try: $query = mysql_query ("INSERT into cv(quiz) values('".$score."')") or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/177914-how-to-use-insert-query/#findComment-938051 Share on other sites More sharing options...
doforumda Posted October 16, 2009 Author Share Posted October 16, 2009 but i want to insert this score in a specific row. if i dont use where then it will add extra row and will be inserted there which i dont want. i want to insert it in a row which already exist. how would i do this? Link to comment https://forums.phpfreaks.com/topic/177914-how-to-use-insert-query/#findComment-938073 Share on other sites More sharing options...
dymon Posted October 16, 2009 Share Posted October 16, 2009 You should use UPDATE statement if you want to change a record: $query = mysql_query ("UPDATE cv SET quiz='{$score}' WHERE id='{$lastId}') or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/177914-how-to-use-insert-query/#findComment-938078 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.