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 Quote Link to comment 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()); Quote Link to comment 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? Quote Link to comment 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()); Quote Link to comment 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.