1

当我尝试浏览表或进行查询时,PhpMyAdmin 无法正确显示字符(或我希望它们显示的方式)。但是,如果 'SET NAMES LATIN1;',一切都会正确显示 包含在查询之前。此外,使用命令行客户端时,一切都在服务器端正确显示。我试图在 phpMyAdmin 首页上将 MySQL 连接排序规则设置更改为 latin1,但它没有效果。我不明白为什么会这样。这是由通信问题或双重编码引起的还是什么?

MySql 服务器设置(来自命令行客户端):

+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | latin1                     |
| character_set_connection | latin1                     |
| character_set_database   | latin1                     |
| character_set_filesystem | binary                     |
| character_set_results    | latin1                     |
| character_set_server     | latin1                     |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+

+----------------------+-------------------+
| Variable_name        | Value             |
+----------------------+-------------------+
| collation_connection | latin1_swedish_ci |
| collation_database   | latin1_swedish_ci |
| collation_server     | latin1_swedish_ci |
+----------------------+-------------------+
4

1 回答 1

0

ini_set('default_charset', 'UTF-8');在您的查询上方添加。

或者,如果您使用的是 mysqli:

$dbc = mysqli_connect($host, $user, $password, $database)
    or die('Error connecting to the database');

if (!mysqli_set_charset($dbc, "utf8")) {
    printf("Error loading character set utf8: %s\n", mysqli_error($dbc));
} else {
    printf("Current character set: %s\n", mysqli_character_set_name($dbc));
}
于 2012-12-10T17:27:49.990 回答