Problem: Chinese characters from DB are not properly rendered in report Description: Chinese characters from DB are not properly rendered in the report, and appear as "???"question marks. Attached a screenshot of the problemhttp://typesetting.altervista.org/sites/default/files/pictures/question_marks.png
My database (MyISAM) encoding is utf8_general_ci
and the information are correctly stored inside (e.g. I can correct view these chinese chars in the db using phpmyadmin)
How can I solve this issue?
I made some research around in google, and found that adding
//Set UTF to solve the question marks issue with Chinese chars
mysql_set_charset("utf8");
can solve this issue, so I made the following simple php file for a simple test:
//Set UTF to solve the question marks issue with Chinese chars
mysql_set_charset("utf8");
// Performing SQL query
$query = 'SELECT * FROM piwik_log_action LIMIT 0 , 30';
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
// Printing results in HTML
echo "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "\t<tr>\n";
foreach ($line as $col_value) {
echo "\t\t<td>$col_value</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";
// Free resultset
mysql_free_result($result);
// Closing connection
mysql_close($link);
?>
and effectively it works, the question marks ??? turn back to the correct Chinese chars! Anyway I don’t know if I can, and eventually where I can add this line into which Piwik file.
What do you think? Is this the correct approach to solve this issue?
Attached is a simple html file with the Piwik tracking code inside.