MySQL 4.1 + support for multiple characters
Character Set Support in MySQL 4.1 has two aspects: Character sets and Collations. Support for character sets is refined to four levels:
Server, database, table and connection.
In practice, even if you set the default character set of the table to UTF-8 and send the query with UTF-8 encoding, you will find that the database is still garbled. The problem lies in this connection layer. The solution is to execute the following sentence before sending the query:
SET NAMES 'utf8';
In PHP, select_db is executed after connect/pconnect.
[@more@]
SET NAMES 'x' statement is equivalent to 3 statements:
SET character_set_client = x;
SET character_set_results = x;
SET character_set_connection = x;
Reference:
http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html