SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Resistance is Futile webgodjj's Avatar
    Join Date
    Nov 2002
    Location
    Madison, WI USA
    Posts
    448
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    update syntax mistake....

    this is a syntax sql error in my php. What is wrong with this syntax?

    PHP Code:
    UPDATE information SET read='y' where id='5'
    ERROR 1064: You have an error in your SQL syntax near 'read='y' where id='5'' at line 1

    Code:
    +---------------------+-----------------------+------+-----+---------------------+----------------+
    | Field               | Type                  | Null | Key | Default             | Extra          |
    +---------------------+-----------------------+------+-----+---------------------+----------------+
    | id                  | mediumint(5) unsigned |      | PRI | NULL                | auto_increment |
    | first_name          | varchar(100)          |      |     |                     |                |
    | last_name           | varchar(100)          |      |     |                     |                |
    | institution         | varchar(100)          |      |     |                     |                |
    | department          | varchar(100)          |      |     |                     |                |
    | address             | varchar(100)          |      |     |                     |                |
    | building            | varchar(100)          |      |     |                     |                |
    | city                | varchar(100)          |      |     |                     |                |
    | state               | varchar(50)           |      |     |                     |                |
    | zip_code            | int(10)               |      |     | 0                   |                |
    | country             | varchar(50)           |      |     |                     |                |
    | telephone           | varchar(30)           |      |     |                     |                |
    | fax                 | varchar(30)           |      |     |                     |                |
    | email               | varchar(100)          |      |     |                     |                |
    | additional_comments | text                  |      |     |                     |                |
    | timestamp           | datetime              |      |     | 0000-00-00 00:00:00 |                |
    | read                | varchar(10)           |      |     |                     |                |
    +---------------------+-----------------------+------+-----+---------------------+----------------+
    Code:
    select * from information where id='5';
    +----+------------+-----------+---------------------+------------+-----------------------+----------+---------+-------+----------+---------------+--------------+--------------+------------------------------+---------------------+---------------------+------+
    | id | first_name | last_name | institution         | department | address               | building | city    | state | zip_code | country       | telephone    | fax          | email                        | additional_comments | timestamp           | read |
    +----+------------+-----------+---------------------+------------+-----------------------+----------+---------+-------+----------+---------------+--------------+--------------+------------------------------+---------------------+---------------------+------+
    |  5 | JJ         | Pagac     | Atomic Coffee Media | Web        | 12 N. Butler St. #102 | Odessa   | Madison | WI    |    53703 | United States | 608-628-0422 | 608-628-0422 | webgod@atomiccoffeemedia.com | This is cool        | 2003-04-02 15:32:14 |      |
    +----+------------+-----------+---------------------+------------+-----------------------+----------+---------+-------+----------+---------------+--------------+--------------+------------------------------+---------------------+---------------------+------+

  2. #2
    chown linux:users\ /world Hartmann's Avatar
    Join Date
    Aug 2000
    Location
    Houston, TX, USA
    Posts
    6,455
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    what kind of field is "read"?

  3. #3
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    read is a reserved word. Either rename it or use backticks:

    PHP Code:
    UPDATE information SET `read`='y' where id=5
    Also, don't put quotes around numbers

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  4. #4
    chown linux:users\ /world Hartmann's Avatar
    Join Date
    Aug 2000
    Location
    Houston, TX, USA
    Posts
    6,455
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by seanf
    read is a reserved word. Either rename it or use backticks:

    PHP Code:
    UPDATE information SET `read`='y' where id=5
    Also, don't put quotes around numbers

    Sean
    dangit, I am really not on today... I need a cup of coffee...

  5. #5
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by seanf
    Also, don't put quotes around numbers
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR


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
  •