2

I use mysql_connect to a database solely defined in UTF-8. Everywhere I can look in the configuration, I see UTF-8 Unicode (utf8) or utf8_general_ci.

However, when I open the PHP connection, then use echo mysql_client_encoding();, I get latin1 as an output, which is pretty unexpected. Is it taken from some kind of PHP/Apache configuration?

Lazlo
  • 123
  • 4

2 Answers2

3

In /etc/mysql/my.cnf add this line under [client]

default-character-set=utf8 
genesis
  • 343
  • 4
  • 15
0

You have to set the encoding for your PHP MySQL connection as it does not read it from your table/database definition. Do it like this:

mysql_set_charset('utf8',$link);
// or in OOP style:
$mysqli->set_charset('utf8');
2ndkauboy
  • 73
  • 3
  • 14