Question

I have a few lines of code that should make a report about the coupons in OpenCart 1.4.9, but I can't get over this 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
 'order where coupon_id = 16' at line 1.
$getcouponinfo1 = mysql_query("select * from order where coupon_id = $coupon_id")
      or die(mysql_error());

The rest of the code can be found here.

Était-ce utile?

La solution

order is a keyword in SQL, you need to quote that table name.

select * from `order` where ...

Autres conseils

"order" IS A MySQL reserved word... If you need to call your table "order" then you need to enclose it in backticks (`) in your sql queries.

Your error message is not related to the query that you originally posted (prior to editing your question), but to this query:

select * from order where coupon_id = $coupon_id

and to the following query where you sum the value of the order

order is a reserved keyword.

You should use `order` instead.

Because order is a reserved word, it is not a good name for a table

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top