Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2008

    Unanswered: 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??

  2. #2
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    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 on the Tiger 800 or the Norton

  3. #3
    Join Date
    Apr 2002
    Toronto, Canada
    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 | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts