Solar Posted October 5, 2010 Share Posted October 5, 2010 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 'like (comment_id, name, like) VALUES ('102','Steven','1')' at line 1 $sql="INSERT INTO like (comment_id, name, like) VALUES ('$_POST[comment_id]','$_POST[name]','$_POST[like]')"; if (!mysql_query($sql,$con)) { die('Error:' . mysql_error()); } echo "You have succesfully liked this comment.<br /><INPUT TYPE=\"button\" VALUE=\"Back\" onClick=\"history.go(-1);\">"; mysql_close($con) Table: comment_idnamelike For some reason, I cannot spot this error. Can you find it? My $con = mysql_connect is a part I left out but it connects fine! The data form is echo'ing fine but it's not inserting into the MySQL Table. Thanks in Advanced! Quote Link to comment https://forums.phpfreaks.com/topic/215176-insert-into/ Share on other sites More sharing options...
gizmola Posted October 5, 2010 Share Posted October 5, 2010 like is a mysql keyword. You have to put `like` where you used it for the tablename and columnname. $sql="INSERT INTO `like` (comment_id, name, `like`) Quote Link to comment https://forums.phpfreaks.com/topic/215176-insert-into/#findComment-1119141 Share on other sites More sharing options...
Solar Posted October 5, 2010 Author Share Posted October 5, 2010 Thanks for the fast reply! Wow, I didn't know it was a keyword! I'll run to google and search MYSQL KEYWORDS It will save a lot of pain for next time Cheers Quote Link to comment https://forums.phpfreaks.com/topic/215176-insert-into/#findComment-1119144 Share on other sites More sharing options...
gizmola Posted October 5, 2010 Share Posted October 5, 2010 Sure no worries... LIKE comes up with select queries ala ... SELECT from people where lastname LIKE 'Smit%'; Quote Link to comment https://forums.phpfreaks.com/topic/215176-insert-into/#findComment-1119162 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.