SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: Insertion Error

  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2006
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Insertion Error

    I'm trying to insert some queries into my DB through phpMyAdmin but I'm getting a syntax error. Any advice?

    MySQL version: 4.1.21-standard

    SQL query:

    Code:
    INSERT INTO `games` ( 'gId', 'gInCategory', 'gSwfFile', 'gName', 'gOrder', 'gVisible', 'gThumb', 'gWidth', 'gHeight', 'gDescription', 'gplays', 'description2', 'des2', 'filetype' )
    VALUES ( 1, 101, 'f-218.swf', '12 Holes of X-Mas', 0, 1, 'f-218.png', 525, 400, "'Pick your putter and go out to putt a hole in one. Move the ball to where you want it then click,move your mouse according to the arrow then click to shoot the ball, and play all twelve holes'", 0, '', '', 1 )
    
    MySQL said: Documentation
    #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 ''gId', 'gInCategory', 'gSwfFile', 'gName', 'gOrder', 'gVisible', 'gThumb', 'gWid' at line 1

    Table Layout:

    Code:
    TABLE `games` (
      `gId` int(11) NOT NULL auto_increment,
      `gInCategory` int(11) NOT NULL default '0',
      `gSwfFile` varchar(255) NOT NULL default '',
      `gName` varchar(255) NOT NULL default '',
      `gOrder` int(1) NOT NULL default '0',
      `gVisible` int(1) NOT NULL default '0',
      `gThumb` varchar(255) NOT NULL default '',
      `gWidth` int(11) NOT NULL default '0',
      `gHeight` int(11) NOT NULL default '0',
      `gDescription` text NOT NULL,
      `gplays` bigint(19) NOT NULL default '0',
      `description2` text NOT NULL,
      `des2` text NOT NULL,
      `gfiletype` int(1) NOT NULL default '0',
      PRIMARY KEY  (`gId`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
    Last edited by hav0k; Dec 28, 2006 at 15:39.

  2. #2
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    dont use ' around column names. use `, but only when necessary.

    see http://www.sitepoint.com/forums/show...29&postcount=4

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2006
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey I tried what you set and cleaned up my SQL to those standards and still nothing. Same ole error. Anything else?

    Code:
    SQL query:
    
    INSERT INTO games( gId, gInCategory, gSwfFile, gName, gOrder, gVisible, gThumb, gWidth, gHeight, gDescription, gplays, description2, des2, filetype )
    VALUES ( 1, 101, 'f-218.swf', '12 Holes of X-Mas', 0, 1, 'f-218.png', 525, 400, "'Pick your putter and go out to putt a hole in one. Move the ball to where you want it then click,move your mouse according to the arrow then click to shoot the ball, and play all twelve holes'", 0, '', '', 1 ) ,
    
    MySQL said: Documentation
    #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 '' at line 1

  4. #4
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    you have an extra comma at the end of your statement. also, make sure that if, for example, you specify 12 columns that you've actually specified 12 data items.

    also some versions of mysql are picky that there be a space after your table name.

  5. #5
    SitePoint Enthusiast
    Join Date
    Mar 2006
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It appears I missed that little comma at the end. It inserted finally so I guess removing the ' cleared up the sytax errors and then the comma just was being a burden. Thanks for all your help!


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
  •