query on 2 dates

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

query on 2 dates

Post 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
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

i think your UserID firld is int type so remove quotes from VALUES('$id',...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it's more like... you need to backtick all your field names, as 'update' at least is a keyword.
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

Post by pleigh »

thanks noob, but the problem is still there....
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post 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 :)
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

Post by pleigh »

solved. changed my update field name to postupdate for update is a keyword....tnx guys... :wink:
Post Reply