Page 1 of 1

query on 2 dates

Posted: Tue Mar 01, 2005 1:33 am
by pleigh
i have a query here:

Code: Select all

$query = "INSERT INTO posts(userID, title, accomplishment, issue, recommendation, date, update)
					VALUES('$id','$t','$a','$i','$r', NOW(), NOW())";
when i tried to insert something, i generated a mysql 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 'update) VALUES('1','first report','some accomplishment','s
how can i solve this?

thanks

Posted: Tue Mar 01, 2005 1:45 am
by n00b Saibot
i think your UserID firld is int type so remove quotes from VALUES('$id',...

Posted: Tue Mar 01, 2005 1:47 am
by feyd
it's more like... you need to backtick all your field names, as 'update' at least is a keyword.

Posted: Tue Mar 01, 2005 1:49 am
by pleigh
thanks noob, but the problem is still there....

Posted: Tue Mar 01, 2005 1:53 am
by n00b Saibot
feyd wrote:it's more like... you need to backtick all your field names, as 'update' at least is a keyword.
heh he, i missed that :oops: . hey pleigh, problem is indeed of the keyword thingy. backtick all the field names :)

Posted: Tue Mar 01, 2005 1:54 am
by pleigh
solved. changed my update field name to postupdate for update is a keyword....tnx guys... :wink: