lynxus Posted October 25, 2009 Share Posted October 25, 2009 Hi Guys, Im having TERRIBLE problems running an insert for some reason the "syntax" is wrong. Ive checked, double checked and copied from other scripts i KNOW that works. I must be being a complete rtard here. Any ideas whats wrong with: mysql_query("INSERT INTO comments (to, from, message) VALUES ('$to', '$from', '$message')") or die(mysql_error()); Erro i get: 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 'to, from, message) VALUES ('test', 'test', 'somemessage')' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/178935-solved-whats-wrong-with-this-basic-insert/ Share on other sites More sharing options...
Mchl Posted October 25, 2009 Share Posted October 25, 2009 'to' is one of MySQL's reserved words (and so is 'from') Quote Link to comment https://forums.phpfreaks.com/topic/178935-solved-whats-wrong-with-this-basic-insert/#findComment-944023 Share on other sites More sharing options...
lynxus Posted October 25, 2009 Author Share Posted October 25, 2009 Ahhhhhhhhhhhhhhhhhhhhhhhhh!!!! Grr i keep forgetting these reserved words! LOL ive had this issue before.. Thanks so much for your help. Good stuff Quote Link to comment https://forums.phpfreaks.com/topic/178935-solved-whats-wrong-with-this-basic-insert/#findComment-944024 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.