Quinn Finney
Quinn Finney

Reputation: 543

MySQL Query Syntax Error on escaped string

INSERT INTO `5` VALUES ('photo', 'headline', 'LA Lakers', 'http://facebook.com/NUMBER', 'Here\'s video from the An...', 'NUMBER', 'http://www.facebook.com/NUMBER/posts/NUMBER', 'NUMBER'), 'https://graph.facebook.com/NUMBER/picture?access_token=AAAGGhZBZB1ZCf4BAD1fNpORWVGtWhUI5u**********************&type=normal')

I get this error when I try this query:

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 ''https://graph.facebook.com/NUMBER/picture?access_token=AAAGGhZBZB1ZC' at line 1

after the individual values (NOT the whole query) have been escaped by php function mysql_real_escape_string.

I have changed all profile ids to the string NUMBER and i added the asterisks to the access token to protect my privacy. Those are not usually there.

Upvotes: 0

Views: 148

Answers (3)

Gyhth
Gyhth

Reputation: 1165

INSERT INTO5VALUES (...), 'https://graph.facebook.com/NUMBER/picture?access_token=AAAGGhZBZB1ZCf4BAD1fNpORWVGtWhUI5u**********************&type=normal'

Take a look at your brackets, they end prematurely, which may be the error.

Upvotes: 0

Vitor Braga
Vitor Braga

Reputation: 2212

You forgot the round brackets in the last value of your insert query...
Further, use apostrophe in the table name...
Like this:

INSERT INTO '5' VALUES ('photo', 'headline', 'LA Lakers', 'http://facebook.com/NUMBER', 'Here\'s video from the An...', 'NUMBER', 'http://www.facebook.com/NUMBER/posts/NUMBER', 'NUMBER', 'https://graph.facebook.com/NUMBER/picture?access_token=AAAGGhZBZB1ZCf4BAD1fNpORWVGtWhUI5u**********************&type=normal')

Upvotes: 0

Matt
Matt

Reputation: 7040

Try this; the last parameter was outside of the parenthesis.

INSERT INTO `5` VALUES ('photo', 'headline', 'LA Lakers', 'http://facebook.com/NUMBER', 'Here\'s video from the An...', 'NUMBER', 'http://www.facebook.com/NUMBER/posts/NUMBER', 'NUMBER', 'https://graph.facebook.com/NUMBER/picture?access_token=AAAGGhZBZB1ZCf4BAD1fNpORWVGtWhUI5u**********************&type=normal')

Upvotes: 1

Related Questions