Why am I getting a MySQLi Syntax error?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Samishii23
    New Member
    • Sep 2009
    • 246

    Why am I getting a MySQLi Syntax error?

    Error: 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 'desc) VALUES (?,?)' at line 1
    Syntax:
    Code:
    INSERT INTO equip_type (name, desc) VALUES (?,?)
    Other Syntax on my program that works:
    Code:
    INSERT INTO equipment (name,purchasedate,purchaseprice,type,lastrepair,serial,usagetype,usageval,brand,dateadded,notes) VALUES (?,?,?,?,?,?,?,?,?,?,?)
    I can't see the problem... Any help?
  • JKing
    Recognized Expert Top Contributor
    • Jun 2007
    • 1206

    #2
    Throw some back ticks around desc and try again. DESC is a reserved word.

    Here is a link if you want some more information on reserved words/keywords in mysql: MySQL Reserved Words

    Comment

    • Wiinie
      New Member
      • Feb 2011
      • 47

      #3
      you have to check your spelling and desc table again .. make sure everything is correct spelling in table's structure

      Comment

      • chetan9529
        New Member
        • Aug 2013
        • 4

        #4
        Second statement is fine.. First having issue because you are using "desc" as column name. It is not possible as "desc" is reserved key word for sorting a column.. create table that having column name as "name" and "descriptio n". Then insert into that.. :)

        Comment

        Working...