jacobb Posted September 12, 2006 Share Posted September 12, 2006 I'm just a beginner and can not seem to get this information to post to the database I have setup. I am trying create a private messaging script but I run into this problem. Here is the code:[quote]conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');$db = mysql_select_db($dbname) or die(mysql_error());$query =("INSERT INTO email (to , subject , message)values('$to', '$subject', '$message')");mysql_query($query,$conn) or die(mysql_error())[/quote]Here is the error message:[quote]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 , subject , message) values('jake', 'test', 'test')' at line 1[/quote]I was hoping someone here could shed some light on this. I have a different script that uses the exact same code and works fine. I'm not sure what's going on. Quote Link to comment Share on other sites More sharing options...
AndyB Posted September 12, 2006 Share Posted September 12, 2006 [b]to[/b] is a [b]reserved word[/b] in MySQL. Don't use reserved words as field names. Solution is to change the name to to mailto or sendto or anything but to (or any other reserved word).http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html in case you want the list of reserved words for future reference Quote Link to comment Share on other sites More sharing options...
jacobb Posted September 12, 2006 Author Share Posted September 12, 2006 [quote author=AndyB link=topic=107848.msg433129#msg433129 date=1158104194][b]to[/b] is a [b]reserved word[/b] in MySQL. Don't use reserved words as field names. Solution is to change the name to to mailto or sendto or anything but to (or any other reserved word).http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html in case you want the list of reserved words for future reference[/quote]That worked. Thank you. Can someone please explain exactly what a reserved word is and what the reserved words are in MYSQL? Quote Link to comment Share on other sites More sharing options...
AndyB Posted September 12, 2006 Share Posted September 12, 2006 [quote author=jacobb link=topic=107848.msg433131#msg433131 date=1158104563]Can someone please explain exactly what a reserved word is and what the reserved words are in MYSQL?[/quote]Sure. That's the link in my initial response. Quote Link to comment Share on other sites More sharing options...
jacobb Posted September 13, 2006 Author Share Posted September 13, 2006 oops....sorry I missed it. Thank you 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.