Home >Database >Mysql Tutorial >从MySQL读取中文数据,显示???(问号)乱码的解决方法

从MySQL读取中文数据,显示???(问号)乱码的解决方法

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-07 16:52:181369browse

从MySQL读取中文数据,显示???(问号)乱码的解决方法:$db = ADONewConnection(rsquo;mysqlrsquo;);$db-gt;PConnect($db

   从MySQL读取中文数据,显示???(问号)乱码的解决方法:

$db = &ADONewConnection(’mysql’);
$db->PConnect($dbhost, $dbusr, $dbpwd, $dbname);
mysql_query(”SET NAMES ‘GBK’”);//加上这句就可以了
$sql=”select * from user where us_id=’admin’”;
$rs=&$db->Execute($sql);
if (!$rs) {
print $db->ErrorMsg();
}
else {
$chinese_name=$rs->fields["ChineseName"];
}
$rs->Close();
$db->Close();
echo “欢迎您!”.$chinese_name;
?>


  上面是使用adodb的写法,,不管用什么方式,只要加上 mysql_query(”SET NAMES ‘GBK’”); 就不会显示???,就正常显示了。

linux

Statement:
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