Error with MySQL syntax

Discussion in 'MySQL' started by blueparukia, Apr 11, 2008.

  1. #1
    Ok, I have made a generator for SQL queries, which normally works, but this one query doesn't:

    
    INSERT INTO groups (name, read, write, edit, delete, comment, admin) VALUES ('Guest','1','0','0','0','0','0' )
    
    Code (markup):
    The PHP error says "MySQL Syntax error around here:
    
     ('Guest','1','0','0','0','0','0' )
    
    Code (markup):

     
    blueparukia, Apr 11, 2008 IP
  2. misja

    misja Active Member

    Messages:
    61
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    95
    #2
    misja, Apr 11, 2008 IP
  3. vpguy

    vpguy Guest

    Messages:
    275
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    "delete" is another reserved word.

    It is good practice to always enclose table and field names in `backquotes`. It's a hard habit to get into at first, and a lot of times you will accidentally press Esc instead of the key below it, but eventually it will become second nature and you will be able to avoid situations like this one.
     
    vpguy, Apr 14, 2008 IP
  4. blueparukia

    blueparukia Well-Known Member

    Messages:
    1,564
    Likes Received:
    71
    Best Answers:
    7
    Trophy Points:
    160
    #4
    Righteo thanks, I'll test later tonight.
     
    blueparukia, Apr 17, 2008 IP
  5. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #5
    mwasif, Apr 17, 2008 IP