Home > Backend Development > PHP Tutorial > 从MYSQL中读出来的数据都是乱码,求帮助,新年第一个有关问题贴,多谢啊

从MYSQL中读出来的数据都是乱码,求帮助,新年第一个有关问题贴,多谢啊

WBOY
Release: 2016-06-13 12:54:12
Original
875 people have browsed it

从MYSQL中读出来的数据都是乱码,求帮助,新年第一个问题贴,谢谢啊!
nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



无标题文档





header("content-type:text/html;charset=utf-8");



$conn=mysql_connect('localhost','root','');
mysql_select_db('test');
$xieru="SELECT * FROM `content`";
$result=mysql_query($xieru,$conn);


for($count=0;$count {

echo mysql_result($result,$count,"people")."
";

echo "
";
}
?>


如上面代码,从表CONTENT 中读出数据字段PEOPLE,怎么操作都是乱码,数据库是UTF-8的编码,求帮助,


------解决方案--------------------
你在 phpmyadmin 中看到的内容是什么?
也贴个图嘛
------解决方案--------------------
查询数据前,先设置下编码

mysql_select_db('test');<br />
mysql_query("set names utf8");<br />
$xieru="SELECT * FROM `content`";
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template