Home >Backend Development >PHP Tutorial >连接mysql服务器报错时,出现乱码解决思路

连接mysql服务器报错时,出现乱码解决思路

WBOY
WBOYOriginal
2016-06-13 12:03:441013browse

连接mysql服务器报错时,出现乱码
页头用了
header('content-type:text/html;charset=utf-8');

try
{
   $this->dbo=new PDO($dsn,$dbuser,$dbpassword);
}
catch(Exception $e)
{
  echo $e->getMessage();
}

连接失败时会报错,但是乱码,IE下编码查看是UTF-8,但是是乱码,如果选择GB2312就不会有乱码了。

页面的格式也是UTF-8。
------解决方案--------------------
mysql 服务器出现故障时的错误信息是按所在操作系统默认字符集给出的
你使用的是 windows,所以错误信息是 gbk 的
不过这并没有关系,毕竟此类错误极少出现

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