很简单的一段代码,可是在IE浏览器上运行时就出现中文乱码,该怎么解决,下面是我的代码:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
<title>创建与MySQL服务器的连接</title>
</head>
<body>
<?php
$link = mysql_connect("localhost", "root", "root") or die("不能连接到数据库服务器!可能是数据库服务器没有启动,或者用户名密码有误!".mysql_error()); //连接Mysql服务器
if($link){
echo "数据库连接成功!";
}
?>
</body>
</html>
数据分析师2017-09-30 22:52:07
What should I do if Chinese garbled characters appear when running PHP to connect to the MySQL server? ? Thank you very much! ! -PHP Chinese website Q&A-What should I do if Chinese garbled characters appear when running PHP to connect to the mysql server? ? Thank you very much! ! -PHP Chinese website Q&A
Please watch and learn.
阿神2016-12-19 09:13:10
可以将
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
改成
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
然后再测试下,其实现在我们都简写成:
<meta charset="utf-8"/>
希望对你有帮助