phpmysqlutf-8utf8-decode

my sql dont return value having special character


my sql query returns no result when just the value to return have special character. exemple :

the query is :

$sql = "SELECT * from categorie ";

    $result = $conn->query(sprintf($sql));

the result was in json

   {"rows":2,"categorie":[{"idCategorie":"8","nomCategorie":"loisir ","imageCategorie":"imgCategorie1.png"},{"idCategorie":"9","nomCategorie":"destination","imageCategorie":"imgCategorie2.png"}],"message":"Liste cat\u00e9gorie","error":0}

But when I change the "nomCategorie" from "loisir" to "quelle loisir avez vous ??

The query dont return any thing or make chane like nomCategorie =cinéma paris

it doesn't work. So I've cancel all the space and the special character and it works


Solution

  • It ok I 've find the solution , I just add that ligne in my config file :

     $conn->query("SET CHARACTER SET utf8");