Jump to content

[SOLVED] MySQL 'INSERT' Issues ...


bsamson

Recommended Posts

I have a table within the database, nnyserve_main. The table is called: ebdopt. I have 3 fields, id, cat, and option.

 

I keep getting the following syntax error:

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 'option) VALUES ('', 'Data Services', '453')' at line 1

 

Here's the script:

 

<?

$cat = "Data Services";
$option="453";

// connection information
$hostName = "localhost";
$userName = "nnyserve_main";
$password = "MYPASSWORDHERE";
$dbName = "$dbname";

// make connection to database
mysql_connect($hostName, $userName, $password) or die("Unable to connect to host $hostName");

mysql_select_db($dbName) or die( "Unable to select database $dbName");

mysql_query("INSERT INTO ebdopt(id, cat, option) VALUES ('', '$cat', '$feature')") or die (mysql_error()); 
?>

 

I am running MySQL version: 5.0.37 w/ php 5.

 

For the life of my I cannot find the error! Any assistance would be greatly appreciated!

Link to comment
Share on other sites

option is a reserved keyword, and as such, cannot be used as a field name.  while it may not trip up the table creation query, it will trip up any data manipulation statements involving that field.

 

http://dev.mysql.com/doc/refman/4.1/en/reserved-words.html

 

PS:  when wanting to let MySQL assign an ID automatically, you can just drop it from the INSERT statement rather than sending it an empty value.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.