Dinesh
Dinesh

Reputation: 29

How to debug MySQL "You have an error in your SQL syntax error"

This is the error

Could not enter data: 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 ')' at line 1

This is my query

$sql = 'INSERT INTO list '. 
   '(bond_amount,bond,prize,prize_amount,draw,draw_date,held_at) '.
   'VALUES ( "bonds", "bonds", prize, p_amount, draw, d_date, held,)';

Upvotes: 0

Views: 3347

Answers (4)

Awais Qarni
Awais Qarni

Reputation: 18006

If You want to use current_date as column name then put current_date between ``(back quotes)

Upvotes: 0

xkeshav
xkeshav

Reputation: 54016

try

INSERT INTO staff_service (customer_id,workorder_no,service_date,`current_date`) 
VALUES (2,021,'3112-21-1',CURDATE())

Upvotes: 3

Jim Garrison
Jim Garrison

Reputation: 86754

current_date is a reserved word in mysql. You should avoid it, but if you really want to use it, you must quote it (in back-quotes).

Upvotes: 5

Gaurav
Gaurav

Reputation: 28755

You can not use current_date as column name. It is a reserve words of mysql.

http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html

Upvotes: 4

Related Questions