从MYSQL中读出来的数据都是乱码,求帮助,新年第一个问题贴,谢谢啊!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
</body>
</html>
<?php
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<10;$count++)
{
echo mysql_result($result,$count,"people")."<br>";
echo "<br>";
}
?>
如上面代码,从表CONTENT 中读出数据字段PEOPLE,怎么操作都是乱码,数据库是UTF-8的编码,求帮助,
------解决方案--------------------你在 phpmyadmin 中看到的内容是什么?
也贴个图嘛
------解决方案--------------------查询数据前,先设置下编码
mysql_select_db('test');
mysql_query("set names utf8");
$xieru="SELECT * FROM `content`";