Retrieving Japanese Text from MySQL using PHP

Our client's website is a multi-language website including Japanese and English.
It was working well until I was asked to develop a simple database ap for the site.
I have run into this problem.
When I try to retrieve the data from MySql using PHP. The data become "??????".(Question Marks)
* The data inside have Japanese and English. 
  So my db and table is defined as CHARSET=utf8 COLLATE=utf8_unicode_ci
* It display in the mySQL administration tools without any problem.
* It display normally in phpMyAdmin(web browser) too.
I know many developers also have run into this problem, so here's the block of code that did the trick for me.
Put this  after the database connection.
mysql_query("SET NAMES 'utf8'")

0 comments: