PHP error when writing using double quotes [duplicate]

-1

I'm trying to write a record to a MySql database, but it gives error because one of the fields gets the value Frantchelle's with quotes.

  

Fatal error: Uncaught exception 'Exception' with message 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server for the right syntax to use near 'S BURGUER'S', idCategory = '1', subcategory = 'HAMBURGERY', description = '', 'at line 1update companies set name =' FRANTCHELLE'S BURGUER'S '', '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' , color = '# 000000', wifi = '0', card = '0', delivery = '1', uf = '26', municipality = 'CUPIRA', schedule = 'SEG. to SáB. BY ORDER. 'where id =' 49 '' in C: \ wamp \ www \ searchfree \ update.php on line 86

    
asked by anonymous 16.02.2018 / 17:59

1 answer

0

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

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

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

See more about addslashes here .

    
16.02.2018 / 18:04