mysqli_set_charset没有设置charset

时间:2014-07-10 17:55:20

标签: mysql character-encoding

$ db是mysqli_connect(...);

创建的数据库的链接
mysqli_set_charset($db,"UTF-8");
die(mysqli_character_set_name($db)); //returns (string) "latin1";

如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

MySQL无法识别" UTF-8"。使用" utf8"。

mysqli_set_charset($db,"utf8");

您可以获得MySQL识别的拼写列表:

SELECT CHARACTER_SET_NAME FROM INFORMATION_SCHEMA.CHARACTER_SETS
WHERE CHARACTER_SET_NAME LIKE 'utf%';