Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display Unicode data with PHP [duplicate]

Tags:

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;  ?> 
like image 740
Egglabs Avatar asked Mar 15 '10 11:03

Egglabs


People also ask

How to set utf-8 encoding in PHP?

PHP UTF-8 Encoding – modifications to your php. The first thing you need to do is to modify your php. ini file to use UTF-8 as the default character set: default_charset = "utf-8"; (Note: You can subsequently use phpinfo() to verify that this has been set properly.)

Does PHP use Unicode?

PHP does not offer native Unicode support. PHP only supports a 256-character set. However, PHP provides the UTF-8 functions utf8_encode() and utf8_decode() to provide some basic Unicode functionality.

What does utf8mb4 mean?

utf8mb4 : A UTF-8 encoding of the Unicode character set using one to four bytes per character. utf8mb3 : A UTF-8 encoding of the Unicode character set using one to three bytes per character. This character set is deprecated in MySQL 8.0, and you should use utfmb4 instead.

What is UTF-8 PHP?

Definition and Usage. The utf8_encode() function encodes an ISO-8859-1 string to UTF-8. Unicode is a universal standard, and has been developed to describe all possible characters of all languages plus a lot of symbols with one unique number for each character/symbol.


1 Answers

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'");  
like image 111
antyrat Avatar answered Sep 21 '22 12:09

antyrat