Jump to content

[SOLVED] Error in Syntax for MySQL INSERT


suttercain

Recommended Posts

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 ('[email protected]', '[email protected]', '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 ('[email protected], '[email protected]', ' at line 1

 

Any advice? Thanks.

 

Link to comment
https://forums.phpfreaks.com/topic/49504-solved-error-in-syntax-for-mysql-insert/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.