Guest Posted June 11, 2010 Share Posted June 11, 2010 I have been looking at this for way to long and need another pair of eyes. Im getting this very simple error and cannot figure out why its drivining me insane. //this is my mysql tried to make it nice and simple to find this problem $query="INSERT INTO emails (To, From, Data) VALUES ('to', 'from', 'data')"; mysql_query($query) or die(mysql_error()); //this is the error im getting 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, Data) VALUES ('to', 'from', 'data')' at line 1 Can somebody look at this for me I am at a stand still thanks Quote Link to comment https://forums.phpfreaks.com/topic/204449-php-mysql-simple-but-odd-error/ Share on other sites More sharing options...
kenrbnsn Posted June 11, 2010 Share Posted June 11, 2010 Enclose the field names in backticks: <?php $query="INSERT INTO emails (`To`, `From`, `Data`) VALUES ('to', 'from', 'data')"; mysql_query($query) or die(mysql_error()); ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/204449-php-mysql-simple-but-odd-error/#findComment-1070621 Share on other sites More sharing options...
PFMaBiSmAd Posted June 11, 2010 Share Posted June 11, 2010 http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html Quote Link to comment https://forums.phpfreaks.com/topic/204449-php-mysql-simple-but-odd-error/#findComment-1070622 Share on other sites More sharing options...
Guest Posted June 11, 2010 Share Posted June 11, 2010 I tried adding single quotes I never thought off adding backticks that did the trick. I could have swore I tried changing the field names but owell it works now thanks so much. Quote Link to comment https://forums.phpfreaks.com/topic/204449-php-mysql-simple-but-odd-error/#findComment-1070625 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.