cs1h Posted February 4, 2009 Share Posted February 4, 2009 Hi, I am trying to insert data into a specific row in a database. My code is, mysql_query($sql = "insert into `$table` (`$photoPlace`) values ('$finalName') WHERE `code1` = '$code1' AND `code2` = '$code2'") or die(mysql_error()); The error is, 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 `code1` = 'xxx' AND `code2` = 'yyy'' at line 1 I'm sure this is a simple thing to solve but I can not work it out. All help is very much appreciated, Cs1h Link to comment https://forums.phpfreaks.com/topic/143743-solved-insert-problem-with-where/ Share on other sites More sharing options...
trq Posted February 4, 2009 Share Posted February 4, 2009 You cannot use a WHERE clause in an INSERT statement. You need to use an UPDATE statement. Link to comment https://forums.phpfreaks.com/topic/143743-solved-insert-problem-with-where/#findComment-754188 Share on other sites More sharing options...
cs1h Posted February 4, 2009 Author Share Posted February 4, 2009 Thank you, Got it working now, I thought I was being stupid. Thanks, Cs1h Link to comment https://forums.phpfreaks.com/topic/143743-solved-insert-problem-with-where/#findComment-754190 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.