Egglabs Egglabs - 1 month ago 10
MySQL Question

How to display Unicode data with PHP

table 'abc' data :

tid title

1 வெள்ளிக்கிழமை ஐ.

2 கோலாகல தொடக்க


$sql=mysql_query("select title from abd where tid='1'");

$row=mysql_fetch_array($sql);

$title = $row['title'];

echo $title;


OutPut displaying like this:



????????????????


But I want to display



வெள்ளிக்கிழமை ஐ.


Solution



<?php
mysql_query ("set character_set_results='utf8'");

$sql=mysql_query("select title from abd where tid='1'");

$row=mysql_fetch_array($sql);

$title = $row['title'];

echo $title;

?>

Answer

Try to set charachter encoding after mysql_connect function like this:

 mysql_query ("set character_set_client='utf8'"); 
 mysql_query ("set character_set_results='utf8'"); 

 mysql_query ("set collation_connection='utf8_general_ci'");