PHP,MySQL,字符无法正确显示. [英] PHP, MySQL, characters not being displayed correctly.

查看:44
本文介绍了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

这篇关于PHP,MySQL,字符无法正确显示.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆