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? Link to comment https://forums.phpfreaks.com/topic/175698-query-help/ 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; Link to comment https://forums.phpfreaks.com/topic/175698-query-help/#findComment-925860 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 Link to comment https://forums.phpfreaks.com/topic/175698-query-help/#findComment-925868 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? Link to comment https://forums.phpfreaks.com/topic/175698-query-help/#findComment-925887 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.