PHP error while saving using quotes

Asked

Viewed 417 times

-1

I am trying to write a record in a Mysql database, however, it gives error because one of the fields receives the value Frantchelle's quotation marks.

Fatal error: Uncaught Exception 'Exception' with message '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’S BURGUER’S', idCategory = '1', subcategory = 'HAMBURGUERIA', Description = '', 'at line 1update empresas set name = 'FRANTCHELLE’S BURGUER’S', idCategory = '1', subcategory = 'HAMBURGUERIA', Description = '', address = 'RUA PEDRO Cândido DA SILVA, 174 ', district = 'GLORIA', latitude = '-8.6116900000000', longitude = '-35.948267400000000', color = '#000000', wifi = '0', card = '0', delivery = '1', Uf = '26', municipality = 'CUPIRA', schedule = 'SEG. à Sáb. ON ORDER. ' Where id = '49'' in C: wamp www buscafree actualiz.php on line 86

  • 1

    Does not use Prepared statements?

  • @rray no use. any hint?

  • 1

    Behold that answer or if you use PDO that other. It is almost certain that this quote that comes from the value closes the single quote and what should close ends by another string.

1 answer

0


Use the function addslashes of PHP in that string, example:

addslashes("Frantchelle's"); //Frantchelle\'s

\(Backslash) in the MySQL is the escape character, so it will not treat this ' as closure of string.

See more about addslashes here.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.