0
INSERT INTO fb_public_figure_posts VALUES ('153080620724_10158531267690725',
    'https://www.facebook.com/DonaldTrump/videos/10158531267690725/',
    '2017-01-23T20:36:07+0000',
    '2017-01-24T00:22:49+0000',
    'Donald J. Trump',
    153080620724,
    'b'My family and I will never forget Friday, January 20th, 2017. Thank you!'',
    'https://www.facebook.com/DonaldTrump/videos/10158531267690725/',
    123471,
    8263,
    153080620724)

when running this sql sentence, it errors:

1064(42000), "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 
'My family and I will never forget Friday, January 20th, 2017. Thank you!'','http' at line 1"

could you please help me for that

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
bin
  • 71
  • 1
  • 5

4 Answers4

0

The line with the 'My family...'-sentence is a bit weird. This looks like a copy-paste-error. If this field has the type of VARCHAR you have to move the sentance in the simple apostrophe

'My family and I will never forget Friday, January 20th, 2017. Thank you!'

Your line is interpreted as

'b' : VARCHAR field

My family and I will never forget Friday, January 20th, 2017. Thank you! : some SQL-Syntax

'' : VARCHAR field

which can't obviously work. A working INSERT would look like this:

INSERT INTO fb_public_figure_posts
       VALUES (
          '153080620724_10158531267690725',
          'https://www.facebook.com/DonaldTrump/videos/10158531267690725/',
          '2017-01-23T20:36:07+0000',
          '2017-01-24T00:22:49+0000',
          'Donald J. Trump',
          153080620724,
          'My family and I will never forget Friday, January 20th, 2017. Thank you!',
          'https://www.facebook.com/DonaldTrump/videos/10158531267690725/',
          123471,
          8263,
          153080620724
             );
Gehtnet
  • 443
  • 10
  • 25
0

The problem is that you have a single quotation in the string you are trying to insert into your database. The single quotation is missing up your INSERT statement. Before putting the text into your INSERT statement, you need to escape any single quotation.

Refer to this previous post "How to escape apostrophe (') in MySql?"

Community
  • 1
  • 1
0

Your sql is not right.'b'My family and I will never forget Friday, January 20th, 2017. Thank you!'', 'b'M...the ' is unnecessary.and ...Thank you!'' the '' is unnecessary.Hope that helps.

blank
  • 29
  • 5
0

it's give error because sql syntax not proper it you insert data with some special character like " ' " so it's need to slashes before special character for example if you add

b'My family and I will never forget Friday, January 20th, 2017. Thank you!'

string into database than b'My give error so you need do add slashes before ' like

b\'My family and I will never forget Friday, January 20th, 2017. Thank you!\'

Mysql function mysql_real_escape_string automatically handle this problem so you just change your string using mysql_real_escape_string function

if you use mysqli than it's mysqli_real_escape_string function

Full Example code

$link = mysqli_connect('localhost', '***', '***');

$r = "b'My family and I will never forget Friday, January 20th, 2017. Thank you!'";
//echo $r;

$r = "b'My family and I will never forget Friday, January 20th, 2017. Thank you!'";
echo mysqli_real_escape_string($link,$r);

Sorry for my bad english

bipin patel
  • 2,061
  • 1
  • 13
  • 22