views:

219

answers:

2

I'm trying to query my database to get some results in Chinese and Japanese languages as follows:

$str = '日本';
$get_character = mysql_fetch_array (mysql_query("SELECT id FROM `mytable` WHERE ch = '$str'"));

print $get_character[0];

The problem is it returns me nothing. For testing purpose I've changed 日本 in database to test and I do get the right id. What's the problem?

Thanks!

+2  A: 

The collation (or maybe encoding) is probably set incorrectly on the field, likely to English or something similar so characters in other languages get mutilated when you try to insert them.

Donnie
+2  A: 

Probably you need to set your connection to UTF-8 (assuming that's what you're using):

mysql_query('SET NAMES "utf8"');
Greg