MyBB Community Forums

Full Version: sql error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
When uploading all my tables again in phpmyadmin i get this error....dont know why its happening.

SQL-query:

INSERT INTO mybb_posts VALUES (1221, 218, 0, 22, '', 0, 24, 'Marlins', 1103592302, ' I guess the Marlins won''t be getting him. And yet, the O'' still have no pitching. But I feel getting Kline was needless for the O''s because they already have BJ Ryan.\n\n[quote]The Orioles today announced that they have signed free agent LHP Steve Kline to a two-year contract. The 32-year reliever went 2-2 with a 1.79 ERA in 67 games for the National League Champion St. Louis Cardinals this past season.\nKline, a durable left-hander who led the National League in appearances for three straight seasons, 1999-2001, has gone 27-30 with a 3.30 ERA in eight seasons in the majors. He began his career as a starter in the Cleveland organization but has pitched at least 66 games in each season since he reached the Majors as a reliever with the Indians in 1997. He pitched in more than 80 games each year from 1999 through 2001, and has averaged 78 appearances a year over the last seven seasons. The Indians traded him to Montreal in August 1997, and he spent four years with the Expos before being traded to the Cardinals in December 2000.\n\nLeft-handed batters hit just .143 (12-for-84) off him last season and
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 '' I guess the Marlins won''t be getting him. And yet, the O'' s
won''t should be won\'t and O'' should be O\', and O''s should be O\'s. And any others I've missed should be replaced from '' to \'
What version of MySQL are you using?
DennisTT Wrote:What version of MySQL are you using?
4.0.24-standard
Quote:When uploading all my tables again in phpmyadmin i get this error....dont know why its happening.

phpMyAdmin does not seem to be adding slashes to the variables (or didn't when you exported your database tables) which it is why it is causing that problem.

You need to replace every instance of ' in your SQL file with \' and then make sure there are no instances of \\'

Chris
what about on double quotes is it suppose to be like this

\\"
You don't need to worry about adding slashes to double quotes.

What I said before was a tad wrong, I was still half asleep. It's going to be VERY complicated and tedious for you to import this data.

Basically you need to add slashes to all of the ' which are going to be in fields.

So basically:

INSERT INTO table (col1,col2) VALUES ('Blah said 'hi'', 'Blah');

Becomes

INSERT INTO table (col1,col2) VALUES ('Blah said \'hi\'', 'Blah');

So you are only adding slashes to the values..
Chris Boulton Wrote:You don't need to worry about adding slashes to double quotes.

What I said before was a tad wrong, I was still half asleep. It's going to be VERY complicated and tedious for you to import this data.

Basically you need to add slashes to all of the ' which are going to be in fields.

So basically:

INSERT INTO table (col1,col2) VALUES ('Blah said 'hi'', 'Blah');

Becomes

INSERT INTO table (col1,col2) VALUES ('Blah said 'hi'', 'Blah');

So you are only adding slashes to the values..

thanks, thats going to be almost impossible to do...lol

so if i have won''t, i just put won\'t?
No because that would still cause an error. A ' signifies the end of a string/variable and prepares for the next. So basically when you're ready to insert data in to the next field along you put in a '.

Any ' used inside your fields needs to be escaped (slashed) so that the database engine does not think it is the end of a field and tries to insert the next.

So

INSERT INTO table (col1,col2) VALUES ('Hi 'blah' Test', 'Hi');

Becomes

INSERT INTO table (col1,col2) VALUES ('Hi \'blah\' Test', 'Hi');

And notice how the two surrounding ' between the first value are not escaped? That is because they signify the contents of a field..