Skip to content Skip to sidebar Skip to footer

Utf8 Characters Not Displaying Properly With Datatables And Yadcf

I have a mysql database that is in UTF8, I've properly output the letters before but cannot make my php do so with datatables using the ajax process. I have tried various methods t

Solution 1:

You need to force utf8 in the PDO connection :

$db = SSP::db($sql_details);
$db->exec("set names utf8");

alternatively, try pass it as a param :

$sql_details = array(
  'user' => 'root', 
  'pass' => 'ryan', 
  'db'   => 'edata', 
  'host' => 'localhost', 
  'charset' => 'utf8' 
);

But this does not work with all PHP versions.

PS: Why do you set the table fields to be of type utf8, but the table character set to be latin1?

Solution 2:

If you have added all the columns as "UTF-8" and still the problem persists then try this

Add these lines on the server side file

mysql_query("SET character_set_client=utf8",$gaSql['link']);
mysql_query("SET character_set_connection=utf8",$gaSql['link']);
mysql_query("SET character_set_results=utf8",$gaSql['link']);

Post a Comment for "Utf8 Characters Not Displaying Properly With Datatables And Yadcf"