views:

88

answers:

1

My table's collation is utf8_general_ci.

My pages are encoded with UTF-8 (without BOM).

Within my pages, my Equiv meta tag sets character set to utf8

My data has Turkish characters in it.

When i output them, it's not showing them as it should be but when i do $db->set_charset("utf8");, it works.

Why do i have to use $db->set_charset("utf8"); even though everything is utf-8 encoded?

+2  A: 

The data is stored as UTF-8 in MySQL, but the PHP's client connection collation is not. Which is why you have to use set_charset in PHP for the DB connection.

Update

php.ini : default_charset utf-8
.htaccess : AddDefaultCharset utf-8

OMG Ponies
Thanks, but can i change it through php.ini or anything like that?
Dada
@Dada: See update
OMG Ponies
i looked up to my mysql server's variables, and all collations and encodings are set to utf-8 so i know problem is not mysql server.Thanks for the update: i checked up that php.ini variable's definition in PHP.net page (http://php.net/manual/en/ini.core.php) and it is same as header('Content-type:utf-8') and `<meta content="charset=utf-8" />`I also checked this: http://www.php.net/manual/en/ini.list.php and i could not find any mysql.default_charset variable so i think i will go with that "set_charset" function.Thanks for reply, i appreciate it.
Dada
@Dada: I found `default_charset` under "Data Handling" on [the php.ini documentation](http://php.net/manual/en/ini.core.php)
OMG Ponies