If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Update date problem??

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-24-08, 01:02
Aamit Aamit is offline
Registered User
 
Join Date: Dec 2008
Posts: 9
Update date problem??

here is my query to update column leave

UPDATE page_views SET leave = NOW() WHERE id = '$id'

it gives error

#1064 - 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 'leave = NOW()

how to solve this??
Reply With Quote
  #2 (permalink)  
Old 12-24-08, 04:33
healdem healdem is online now
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,262
so presumably this is a PHP problem
first off you would be better supplying the relavant lines of PHP code
ie where you set the SQL upto and including the execution of the SQL.

on the face of it the SQL looks OK
I'd want to check the table name are correctly spellt and CaPiTaLiSeD. On windows it doesn't matter (on column names, but it does on table names oddly), on *NIX it matters at all times
Id want to check the column is defined as a datetime
Id want to check that the NOW function is valid for the version of MySQL I was using
Id want to check that I wasn't using a MySQL reserved word

I'm a little suspicious of your where clause.. because Im used to numeric columns with a suffix of "ID", and therefore the ' would be suprerfluous
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #3 (permalink)  
Old 12-24-08, 04:58
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
the error occurs at the word "leave" (right where the message says)

LEAVE is a reserved word, so you have to backtick it

UPDATE page_views SET `leave` = NOW() WHERE id = $id

healdem is right about not putting quotes around values being compared with or inserted into numeric columns -- mysql will do an implicit conversion, but other database systems are not as forgiving and will toss an error there, too
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On