使用PHP + MySQL的utf-8编码问题 [英] Issue with utf-8 encoding using PHP + MySQL
本文介绍了使用PHP + MySQL的utf-8编码问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将数据从 MySQL 4 (它们最初设置为 latin2 encoding
)移至 MySQL 5 并设置编码为 utf-8
。它在 phpMyAdmin
中看起来不错,而 utf-8
是好的。但是网站上有问号而不是一些字符!网站编码也设置为 utf8
,所以我不明白问题在哪里。
PHP 和 HTML 文件也设置为 utf8
我不知道...
解决方案
尝试查询
SET NAMES utf8
在您的应用程序中的任何查询之前
I moved data from MySQL 4 (they were originally set to latin2 encoding
) to MySQL 5 and set encoding to utf-8
. It looks good in phpMyAdmin
, and utf-8
is okay. However there are question marks instead of some characters on website! The website encoding is also set to utf8
so I dont understand where the problem is.
PHP and HTML files are also set to utf8.
I have no idea...
解决方案
try query
SET NAMES utf8
before any query in your application
这篇关于使用PHP + MySQL的utf-8编码问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文