SQL Syntax Problem?? Help!

Discussion in 'Programming' started by upnya, Nov 20, 2006.

  1. #1
    Hello, I'm trying to import an .sql file to my arcade website and I'm getting some strange errors. Can someone who knows SQL look at this line of code and tell me if there is something wrong with it? Thanks!

    INSERT INTO `games` ('gameid', 'gametitle', 'gamedesc', 'gamekeywords', 'gamefile', 'gameheight', 'gamewidth', 'category', 'timesplayed', 'totalvotes', 'totalvotepoints', 'rating', 'gameicon', 'gamestatus', 'playedtoday', 'gamelocation', 'iconlocation', 'instructions', 'filetype', 'customcode') VALUES (2,'12 Many','The screen flashes quickly and it ask you how many stars you seen. Can get quite challenging.','12 Many','1221.swf',360,480,1,38,0,0,0.00,'1221.png',1,0,0,0,'',1,''),

    Anything look strange (except the bad grammer, lol)?
     
    upnya, Nov 20, 2006 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,827
    Likes Received:
    4,541
    Best Answers:
    123
    Trophy Points:
    665
    #2
    I'm guessing it's an extended insert, and the values bit repeats over and over.

    this
    should be
    when listing the fields you are inserting into you use backticks ` rather than single quotes.
    when listing the values for the fields you use double or single quotes (the singles you have are fine.
     
    sarahk, Nov 20, 2006 IP
  3. upnya

    upnya Active Member

    Messages:
    420
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #3
    UGH... Tried replacing them like you said and here's what I get:

    "Error
    SQL query:

    INSERT INTO `games` ( `gameid` , `gametitle` , `gamedesc` , `gamekeywords` , `gamefile` , `gameheight` , `gamewidth` , `category` , `timesplayed` , `totalvotes` , `totalvotepoints` , `rating` , `gameicon` , `gamestatus` , `playedtoday` , `gamelocation` , `iconlocation` , `instructions` , `filetype` , `customcode` )
    VALUES ( 1, '12 Holes of X-Mas', "'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'", '12 Holes of X-Mas', 'f-218.swf', 400, 525, 1, 7236, 0, 0, 5.00, 'f-218.png', 1, 0, 0, 0, '', 1, '' ) ,

    MySQL said:

    #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"
     
    upnya, Nov 20, 2006 IP
  4. druidelder

    druidelder Peon

    Messages:
    285
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Is your gameID set to autogenerate? If so, then you shouldn't be inserting any values for it.
     
    druidelder, Nov 20, 2006 IP
  5. upnya

    upnya Active Member

    Messages:
    420
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #5
    I'm code illiterate, how might I find this out?
     
    upnya, Nov 20, 2006 IP
  6. sarahk

    sarahk iTamer Staff

    Messages:
    28,827
    Likes Received:
    4,541
    Best Answers:
    123
    Trophy Points:
    665
    #6
    In phpMyAdmin look at the structure of the table and see if it has a field with "auto increment"

    but you error is here I think.
    You have two lots of quotes around the description.

    Do you want to paste your script with [ code ] tags around it?
     
    sarahk, Nov 20, 2006 IP
  7. daboss

    daboss Guest

    Messages:
    2,249
    Likes Received:
    151
    Best Answers:
    0
    Trophy Points:
    0
    #7
    try this:

    1. remove the last comma in your statement
    2. remove the backticks

    INSERT INTO games
    (gameid, gametitle, gamedesc, gamekeywords, gamefile, gameheight, gamewidth, category, timesplayed, totalvotes, totalvotepoints, rating, gameicon, gamestatus, playedtoday, gamelocation, iconlocation, instructions, filetype, customcode)
    VALUES
    (2,'12 Many','The screen flashes quickly and it ask you how many stars you seen. Can get quite challenging.','12 Many','1221.swf',360,480,1,38,0,0,0.00,'1221.png',1,0,0,0,'',1,'')
    Code (markup):
     
    daboss, Nov 20, 2006 IP
  8. sarahk

    sarahk iTamer Staff

    Messages:
    28,827
    Likes Received:
    4,541
    Best Answers:
    123
    Trophy Points:
    665
    #8
    but leave the backticks in!
     
    sarahk, Nov 20, 2006 IP
  9. daboss

    daboss Guest

    Messages:
    2,249
    Likes Received:
    151
    Best Answers:
    0
    Trophy Points:
    0
    #9
    no harm trying that out... i've seen installs where the backticks cause problems... ;)
     
    daboss, Nov 20, 2006 IP
  10. upnya

    upnya Active Member

    Messages:
    420
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #10
    Here's the script I'm trying to get to work - So far, none of the suggestions have worked :(

    I really appreciate all the ongoing help though!

    www.seocraze.com/phpas.zip
     
    upnya, Nov 20, 2006 IP
  11. sarahk

    sarahk iTamer Staff

    Messages:
    28,827
    Likes Received:
    4,541
    Best Answers:
    123
    Trophy Points:
    665
    #11
    open the file and do a global replace

    ),

    becomes

    );

    and try again.
     
    sarahk, Nov 20, 2006 IP
    daboss likes this.
  12. daboss

    daboss Guest

    Messages:
    2,249
    Likes Received:
    151
    Best Answers:
    0
    Trophy Points:
    0
    #12
    that should so it ;)
     
    daboss, Nov 20, 2006 IP
  13. upnya

    upnya Active Member

    Messages:
    420
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #13
    Thanks guys, but still getting:

    Error
    SQL query:

    INSERT INTO `games` ( 'gameid', 'gametitle', 'gamedesc', 'gamekeywords', 'gamefile', 'gameheight', 'gamewidth', 'category', 'timesplayed', 'totalvotes', 'totalvotepoints', 'rating', 'gameicon', 'gamestatus', 'playedtoday', 'gamelocation', 'iconlocation', 'instructions', 'filetype', 'customcode' )
    VALUES ( 1, '12 Holes of X-Mas', "'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'", '12 Holes of X-Mas', 'f-218.swf', 400, 525, 1, 7236, 0, 0, 5.00, 'f-218.png', 1, 0, 0, 0, '', 1, '' );

    MySQL said:

    #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 ''gameid', 'gametitle', 'gamedesc', 'gamekeywords', 'gamefile',


    I give up, maybe its something wrong with Godaddy.
     
    upnya, Nov 20, 2006 IP
  14. sarahk

    sarahk iTamer Staff

    Messages:
    28,827
    Likes Received:
    4,541
    Best Answers:
    123
    Trophy Points:
    665
    #14
    Nope, don't give up

    but you've put single quotes back in where they should be backticks or nothing (as per daboss's recommendation)

     
    sarahk, Nov 20, 2006 IP
  15. daboss

    daboss Guest

    Messages:
    2,249
    Likes Received:
    151
    Best Answers:
    0
    Trophy Points:
    0
    #15
    have you tried what i mentioned in post 7?
     
    daboss, Nov 20, 2006 IP
  16. upnya

    upnya Active Member

    Messages:
    420
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #16
    Yeah, tried that too. You guys seem to know what you're talking about. I really think it must be something I'm doing wrong to import it or something.

    Should be a 2 sec. job according to the guy on here I bought it from. Oh well.
     
    upnya, Nov 20, 2006 IP
  17. daboss

    daboss Guest

    Messages:
    2,249
    Likes Received:
    151
    Best Answers:
    0
    Trophy Points:
    0
    #17
    what is the " character doing here - in bold red?

    try this:

    INSERT INTO games ( gameid, gametitle, gamedesc, gamekeywords, gamefile, gameheight, gamewidth, category, timesplayed, totalvotes, totalvotepoints, rating, gameicon, gamestatus, playedtoday, gamelocation, iconlocation, instructions, filetype, customcode ) 
    VALUES ( 1, '12 Holes of X-Mas', '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'", '12 Holes of X-Mas', 'f-218.swf', 400, 525, 1, 7236, 0, 0, 5.00, 'f-218.png', 1, 0, 0, 0, '', 1, '' );
    Code (markup):
     
    daboss, Nov 20, 2006 IP
    obenix likes this.