Gossamer Forum
Home : General : Perl Programming :

execute failed

Quote Reply
execute failed

I am wondering if mysql have a limit on how much fields you can have in a table. I got stuck with stupid code that gives me an error : DBD::mysql::st execute failed: 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 'check,payment,salesperson,Customer,Qty13day,Qty23day,qtycr100,q at controller.pl line 123.
The code looks fine to me.

$dbs = $dbc->prepare("INSERT INTO purchase(sal,first,lastname,company,address,city,state,zip,country,phone,
Prc23day,Prc33day,Prc43day,status) VALUES ($ref->{salutation},$ref->{first_name},$ref->{last_name},$ref->{company},$ref->{address},$ref->{city},$ref->{billto_state},$ref->{zip},$ref->{country},$phone,$fax,$ref->{email},$cell,$ref->{check_number},$ref->{payment_type},$ref->{salesperson_number},$ref->{Customer_Type},$ref->{Qty13day},$ref->{Qty23day},$ref->{qtycr100},$ref->{qtycr500},$ref->{qtycr1000},$ref->{qtycr5000},$ref->{prcr100},$ref->{prcr500},$ref->{prcr1000},$ref->{prcr5000},$ref->{totals},$ref->{tax},$ref->{Qty33day},$ref->{Qty43day},$ref->{Prc13day},$ref->{Prc23day},$ref->{Prc33day},$ref->{Prc43day},'o')");

$count = $dbs->execute();

I am given up for now. Ive lost too much sleep last night. Please if any of you can spot the error I would appreciate the help. I've already checked I am connecting to the database with my username and password.
Quote Reply
Re: [TheSafePick] execute failed In reply to
It looks like "check" is a reserved word in MySQL: http://dev.mysql.com/.../reserved-words.html. Either change the name of that column or use backticks to name the column in your statements.