PHP,MySQL,字符无法正确显示.

问题描述:

我有一个数据库,其中包含玩家的名字(游戏的统计数据库),但是当我使用mysqli查询获取玩家的名字时,我得到了一些更奇怪的结果.

I have a database that has the names of players (it's stats db for game), but when i fetch the player names with mysqli query i'm getting some wierd results.

例如,字符Α†Ω"显示为? ?".

For example the characters "Α†Ω" are displayed as "?�?".

  • 当我在phpmyadmin中打开表格时,字符正确显示
  • html内容类型为utf-8(为了确定,我什至从phpmyadmin复制了元数据.)
  • 数据库及其表是utf8_general_ci

我该怎么做才能正确显示这些(和其他)字符?

What can i do to display these (and other) characters correctly?

您必须将连接字符集设置为utf8.

You have to set the connection charset to utf8.

执行以下功能: http://php.net/manual/en /mysqli.set-charset.php

或执行以下查询:

 SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8