UTF-8 Charset error when returning from database

-2

My system has a charset error, but it is only with the data returned from the database. My charset in the HTML is right, the database is also right, and php.ini is also right.

How do I solve the problem? Special characters are returning ? .

    
asked by anonymous 25.09.2015 / 16:53

1 answer

2

Set the desired charset at run time.

If you are using PDO, do:

$pdo->exec('SET NAMES utf8');

In Mysqli :

mysqli_query($mysql, 'SET NAMES utf8')
    
25.09.2015 / 16:55