php读取中文出现乱码-学生问我?
时间:2010-07-16 来源:本站原创 作者:yuge 浏览次数:
今天一个学生问我,老师我怎么按写的语句,读取出来输出,中文出现乱码,
ConnOpen($GLOBALS['dbConfig']['host'],$GLOBALS['dbConfig']['login'],$GLOBALS['dbConfig']['password'],$GLOBALS['dbConfig']['database']);//利用$GLOBALS超全局变量读取数据库链接配制。
$results=mysql_query("select * from table order by id desc limit $num") or die('sql error');
我告诉他你百度一下不就知道了,我们可以在mysql_query()之前来解决这个问题。
修改后的代码如下:ConnOpen($GLOBALS['dbConfig']['host'],$GLOBALS['dbConfig']['login'],$GLOBALS['dbConfig']['password'],$GLOBALS['dbConfig']['database']);//利用$GLOBALS超全局变量读取数据库链接配制。
mysql_query("set names gb2312");//设置读出编码
$results=mysql_query("select * from table order by id desc limit $num") or die('sql error');
版权归原作者所有,内容仅供参考学习,不得用于商业用途。