suttercain Posted May 1, 2007 Share Posted May 1, 2007 Hi guys, I am running the following code to try and insert data into the MySQL Table: <?php $storyId = $_SESSION['storyId']; $recipient = $_POST['email']; $from = $_POST['name']; $date = date("Y-m-d H:i:s"); require ('get_connected.php'); $q ="INSERT INTO newsSent (to, from, storyId, date) VALUES ('$recipient', '$from', '$storyId', '$date')"; $rs = mysql_query($q) or die("Error In Query: <pre>$q</pre><br>".mysql_error()); ?> Sadly I get the following error but cannot locate the problem in the syntax: INSERT INTO newsSent (to, from, storyId, date) VALUES ('spcronin@domain.com', 'scronin@domain.com', '52', '2007-05-01 12:55:42') 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, storyId, date) VALUES ('spcronin@domain.com, 'scronin@domain.com', ' at line 1 Any advice? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/49504-solved-error-in-syntax-for-mysql-insert/ Share on other sites More sharing options...
Barand Posted May 1, 2007 Share Posted May 1, 2007 Don't use reserved words as field names (to, from) Quote Link to comment https://forums.phpfreaks.com/topic/49504-solved-error-in-syntax-for-mysql-insert/#findComment-242652 Share on other sites More sharing options...
suttercain Posted May 1, 2007 Author Share Posted May 1, 2007 Thank you Barrand, that solved the issue. I have printed this out: http://www.htmlite.com/mysql002a.php and posted it above my desk. Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/49504-solved-error-in-syntax-for-mysql-insert/#findComment-242669 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.