views:

40

answers:

3

i have a proble, when insert something in foreign language into database. i have set the collation of database to utf8_general_ci(try utf8_unicod_ci too). but when i insert some text into table, it was saved like this

Õ€Õ¡ÕµÕ¥Ö€Õ¥Õ¶ Ô±Õ¶Õ¸Ö‚Õ¶

but when i read from database, text shows in correct form. it looks like that only in database.

i have set encoding in my html document to charset=UTF-8

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

and i set

mysql_query("SET NAMES UTF-8");
mysql_query("SET CHARACTER SET UTF-8");

when conecting to database. so i think that i' ve done everything, but it still save in that anknown format. could you help me. thanks in advance

+1  A: 

It looks like maybe your phpmyadmin isn't using the correct charset. In your phpmyadmin folder, open config.default.php and edit the lines

$cfg['DefaultCharset'] = 'iso-8859-1';
$cfg['DefaultLang'] = 'en-iso-8859-1';

To your chosen encoding.

adam
@adam can i do that by some functions?( like ini.set() in php), because i haven't permission to change them on the hosting!
Syom
I don't think so. It should pick up the encoding automatically (and correctly). You could contact your host or install your own copy.
adam
@adam but there isn't any config.default.php file. only config.inc.php and config.sample.inc.php.
Syom
Then it's config.inc.php
adam
@adam there aren't such thing in both of them:(
Syom
Ok. If it's there, it might be under a different name. It's really not my area, so you'll have to have a look about
adam
A: 

It is suggested to use mysql_set_charset() instead of "SET NAMES" query, however the impact should be the same.

naivists
@naivists what is the difference?
Syom
+2  A: 

I believe you have to SET NAMES utf8, instead of UTF-8, in MySQL.

WishCow
i don't ubderstand. rewrite please
Syom
Try mysql_query("SET NAMES utf8");.
WishCow
@WishCow congratulation. it works. thanks very very veeeeery much:)
Syom