herghost Posted September 27, 2009 Share Posted September 27, 2009 Hi All, I am getting this message when trying to run a query oh dear1 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='60'' at line 3 The Query if(empty($view)) { $view=1; $sql4="INSERT INTO forum_question(view) VALUES('$view') WHERE id='$id'"; $result4=mysql_query($sql4)or die ("oh dear1 " .mysql_error()) ; } What have i got wrong? Quote Link to comment Share on other sites More sharing options...
RichardRotterdam Posted September 27, 2009 Share Posted September 27, 2009 Try and echo out your sql and see what the complete query looks like echo $sql4; Quote Link to comment Share on other sites More sharing options...
herghost Posted September 27, 2009 Author Share Posted September 27, 2009 INSERT INTO forum_question(view) VALUES('1') WHERE id='60' This is the result of the echo. Should be table = forum_question coloum = view Bloody thing Quote Link to comment Share on other sites More sharing options...
RichardRotterdam Posted September 27, 2009 Share Posted September 27, 2009 You do realize that there is no where condition for an INSERT right? http://dev.mysql.com/doc/refman/5.1/en/insert.html If you want to insert a new record leave out the where Perhaps you meant an update query? 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.