0

I JSON decode a page with PHP, but sometimes there's a name like 'M'gladbach' or 'Côte d'Ivoire' and then the SQL sees the first single quote as a stop so it gives me the error after the 'Côte d' Can somebody help me with this problem ? I know you can do 'Côte d''Ivoire' but as I get all the info from a API I can't put double quotes in it. Thanks a lot.

2 Answers2

1

use double quotes

"M'gladbach" 
0

The proper way to do it is

$item = "Côte d'Ivoire";
$escaped_item = mysqli_escape_string($item);
printf("Protected string : %s\n", $escaped_item);

Now it is safe to put e.g. in a database.

Kevin
  • 2,813
  • 3
  • 20
  • 30