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

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

WBOY
Release: 2016-06-13 12:03:44
Original
986 people have browsed it

连接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 的
不过这并没有关系,毕竟此类错误极少出现

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