php链接mysql服务器时运行就出现中文乱码怎么办??十分感谢!!
phpcn_u228
phpcn_u228 2016-12-18 13:31:57
0
2
993

很简单的一段代码,可是在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>


phpcn_u228
phpcn_u228

reply all(2)
数据分析师

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.

阿神

可以将

<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"/>

希望对你有帮助

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!