FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


MySQL statement error (got me going)





friscofrankie
Executing an insert into one table of my DB chokes my script.
I get an error:
Code:

Error: Column count doesn't match value count at row 1


The row count matches and the fields are large enpough to contain the data.
Table structure is:
Code:

 Field                 Type                 Null       Key      Default   

 order_id               int(11)                   PRI               0                       
 order_date           timestamp      YES                     CURRENT_TIMESTAMP       
 order_busname        varchar(50)      YES                 NULL                     
 order_fname        varchar(50)                                       
 order_lname         varchar(50)                                       
 order_address      varchar(125)                                     
 order_address2        varchar(125)    YES                NULL                     
 order_city             varchar(50)                                       
 order_state           varchar(20)                                       
 order_zip              varchar(10)      YES         NULL                     
 order_tel               varchar(25)                                       
 order_country       varchar(50)                                       
 order_email           varchar(100)                                     
 item_total             float(6,2)                         0.00


here's the code:
Code:

$cust_info_sth   =   sprintf("insert into cust_order_info (order_id, order_busname, order_fname, order_lname, order_address, order_address2, order_city, order_state, order_zip, order_tel, order_country, order_email, item_total) values('$order_id, $busname, $fname, $lname, $addr1, $addr2, $city, $state, $post_code, $tel, $country, $email, %01.2f')", mysql_real_escape_string($total));


actual statement passed to MySQL:
Code:


SQL:insert into cust_order_info (order_id, order_busname, order_fname, order_lname, order_address, order_address2, order_city, order_state, order_zip, order_tel, order_country, order_email, item_total) values('20082, Isaan imports, joe, Blow, #123 432 65 Moo 8 T. whiteelephant , none, big city, some prov, 12345, 11 3 123 0203, Thailand, joe@somedomain.com, 541.30')

So, I matched up the fields with the values in a spreadsheet to see if they mached; they do. There are thirteen fields and thirteen values. I do not insert into the timestamp field. this should not be a problem.
I tried splitting the insert in to two parts same thing. In another statement I insert one value into a four column table with no problem.
Anybody see an error or know of a certain bug(feature) that might cause this? not looking for a magic bullet but if anyone can point me in the right direction or sees a dumb mistake; I'd appreciate the help.
BlackSkad
You need to place every value between single ', like:
Code:
VALUES ('bla1', 'bla2',...)


Right now, you have a quote at the beginning and one at the end. That's why he sees it as one value.

BlackSkad
friscofrankie
Shocked
I owe you a pint, or two, I cold have stared at that all day and never noticed it.
Hell, maybe all week.

Thank you
BlackSkad
You're welcome Smile
This is called a community for something, were here to help eachother :p

Greatz,
BlackSkad
Related topics
SMF Forum is not working
phpBB Error, seems to be a MYSQL DB error...
Suppressing mysql error
mysql base error please help
MySQL socket error
SQL error on my site
Get error on ' and " when executing mysql statement
SMF forum error?
phpMyAdmin - MySQL Ext error...
MySQL connection error on Server 2?
MYSQL Database Error on Server 2
MySQL - Session error?
Mysql ERROR
MySQL Error
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.