For some reason, it doesn't work out. In the code, PDO is used as below:
new PDO("mysql:host={$dbhost};dbname={$db};charset=utf8",$userid, $pw,
array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
Also, I check mysql, all setting is utf8 as below. Use Aqua Data Studio to display, it doesn't show correct, even correct by connecting to mysql on Windows. More strange is another page using mysqli displaying the content correct. Do this mean the problem is PDO?
Before the string is sent to mysql, it's handled by addslashes function.
Thanks,
mysql> show variables like 'char%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
mysql> show variables like 'collation%';
+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| collation_connection | utf8_general_ci |
| collation_database | utf8_unicode_ci |
| collation_server | utf8_unicode_ci |
+----------------------+-----------------+