SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict o~~Goatee~~o's Avatar
    Join Date
    Jan 2004
    Location
    North Yorkshire UK
    Posts
    350
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    update query problem

    Hi there

    I seem to be having an issue which really shouldn't be an issue but I'm obviously missing something..... I want to update 1 value in my MySQL db through a PHP script. I'm passing my query to a function that I use for all my queries but it doesn't work. Here is the php:
    Code:
    $result = mySQLQuery("UPDATE mail SET read = 1 WHERE mail_id = $mailid AND client_id = 0");
    and here is my error message:
    Query problem ! MySQL says: You have an error in your SQL syntax near 'read = 1 WHERE mail_id = 12 AND client_id = 0' at line 1 and the query is UPDATE mail SET read = 1 WHERE mail_id = 12 AND client_id = 0
    Am I overlooking something very simple here? All column names, table names and variable names are correct.

    Many thanks

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,338
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    READ is a reserved word, so you have to put it in backticks

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Addict o~~Goatee~~o's Avatar
    Join Date
    Jan 2004
    Location
    North Yorkshire UK
    Posts
    350
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    lol, d'oh. I thought I was going mad for a second. Thanks for pointing that out


Bookmarks

Posting Permissions

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