Jump to content

Simple Query Error


Wstar

Recommended Posts

Having some issues with an error.  Its just a simple query, yet I can't figure it out.

 

MySQL Version: 5.0

 

 

MySQL Statement:

 

$query = "INSERT INTO invoices (invoice_number, date, total, 
					first_name, last_name, email, 
					address, post_code, state, 
					order, comments)
         VALUES ('$invoice',  '$date',  '$total', 
		       '$first',  '$last',  '$email', 
		       '$address',  '$zip',   '$state', 
		       '$order',  'N')";

 

MySQL Error:

INSERT INTO invoices (invoice_number, date, total, first_name, last_name, email, address, post_code, state, order, comments) VALUES ('1', 'February 3, 2010, 9:15 am', '4.95', 'Jerrod', 'Davenport', 'jerr', '404 E Vernon, Apt A3', '61761', 'IL', 'a:2:{i:0;N;i:1;a:7:{s:10:"product_id";s:1:"1";s:8:"quantity";s:1:"1";s:4:"name";s:18:"The Last Ute Cheif";s:5:"cover";s:1:"p";s:9:"unitPrice";s:5:"15.00";s:6:"extra1";s:0:"";s:6:"extra2";s:0:"";}}', 'N')

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 'order, comments) VALUES ('1', 'February 3, 2010, 9:15 am', '4.95'' at line 2

 

I can't find any problem.  Please, any suggestions?

Link to comment
Share on other sites

put ticks around your column names....

 

INSERT INTO invoices (`invoice_number`, `date`, `total`,

`first_name`, `last_name`, `email`,

`address`, `post_code`, `state`,

`order`, `comments`

 

 

it's messing up at the order because that is a sql command, it thinks your telling it to sort information, not providing a column name.

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.