-1

My utf-8 is not working in php with pdo. when i store België i have in my db België in my index page of html i have <meta content="text/html" charset="utf-8" />

and in my php page i have

I have tried this but this isn't working

$db = new PDO("mysql:host=$host;dbname=$dbname",$username,$password, array(PDO::MYSQL_ATTR_INIT_COMMAND =>  "SET NAMES utf8"));
         $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

When i load the data from the db into a table then i have again the right value België. But with geocoder when i took a longer value like Jan Breydelstadion, Koning Leopold III-laan, Brugge, België then i get a error Zerro_results.

But when i change the word Jan Breydelstadion, Koning Leopold III-laan, Brugge, België to Jan Breydelstadion, Koning Leopold III-laan, Brugge, België in my mysql

then my geocoder error is gone.

1 Answers1

0

Have you tried to also add the charset to your connection string? As this :

$db = new PDO("mysql:host=$host;dbname=$dbname;charset=utf8",$username,$password, array(PDO::MYSQL_ATTR_INIT_COMMAND =>  "SET NAMES utf8"));
         $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
zoubida13
  • 1,738
  • 12
  • 20