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
https://forums.phpfreaks.com/topic/190802-simple-query-error/
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
https://forums.phpfreaks.com/topic/190802-simple-query-error/#findComment-1006130
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.