-3

MySQL keeps reporting an error when executing the SQL query. Everything looks right to me, but Ive been looking at it for about an hour now.

"INSERT INTO invoices 

(total, generated, account, market, status, name, hash) 

VALUES 

('$total', Now(), '$aid', '$mid', '$name', 'Active', '$hash')"

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 'desc, account, market, status, name, hash) VALUES ('499.99', NOW(), 'System gene' at line 1 (SQL: INSERT INTO invoices (total, generated, desc, account, market, status, name, hash) VALUES ('499.99', NOW(), 'System generated invoice during Market setup/activation.', '6', '9', 'Zac Company - Chandler', 'Active', 'b0521f6668cb87de009866b67b25b458')

I think this is an easy fix that just needs fresh eyes.

Zac Brown
  • 5,905
  • 19
  • 59
  • 107

1 Answers1

1

There it is

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 'desc, account,

desc is a reserve word and so must be escaped with back quote

`desc`

Also, total is a numeric column; so no need of quoting it

Your sql query should be like below

INSERT INTO invoices (total, generated, `desc`, account, market, status, name, hash) 
                                          <--Here
VALUES (499.99, NOW(), 'System generated invoice during Market setup/activation.',
'6', '9', 'Active', 'Zac Company - Chandler',  'b0521f6668cb87de009866b67b25b458')
Rahul
  • 76,197
  • 13
  • 71
  • 125
  • Thanks for the prompt response, but even when I just take desc out, I get the same error. – Zac Brown May 07 '14 at 18:44
  • @ZacBrown, edited answer. Check now. – Rahul May 07 '14 at 18:47
  • thanks so much! I had been looking at this stupid thing for an hour, after no sleep last night. It's hard to find people on SO these days that will actually help, so +1 for you! Thanks! – Zac Brown May 07 '14 at 18:52