<?php
$conn = mysql_connect("localhost","root","1234") or die("不能连接数据库服务器:".mysql_connect_errror());
mysql_select_db("messtest",$conn);
$results = mysql_query("select * from gbbook");
mysql_query($results,$conn);mysql_query("setnames 'utf8'",$conn);//使用中文编码;
while($row = mysql_fetch_row($results)){
echo $row[0]."".$row[1]."".$row[2]."".$row[3]."".$row[4];
echo"<br />";
}
mysql_close($conn);
?>
$conn = mysql_connect("localhost","root","1234") or die("不能连接数据库服务器:".mysql_connect_errror());
mysql_select_db("messtest",$conn);
$results = mysql_query("select * from gbbook");
mysql_query($results,$conn);mysql_query("setnames 'utf8'",$conn);//使用中文编码;
while($row = mysql_fetch_row($results)){
echo $row[0]."".$row[1]."".$row[2]."".$row[3]."".$row[4];
echo"<br />";
}
mysql_close($conn);
?>
mysql_query("setnames 'utf8'",$conn);//使用中文编码;
mysql_query("setnames 'utf8'",$conn);
mysql_query("set names 'gb2312'",$conn);
mysql_query("set names 'gbk'",$conn);
全都试过,都没用啊!我phpadmin里面用的是gb2312;
header("content-type:text/html;charset=gbk")
//假如是纯php不包括html代码就加上下面这段代码
header("content-type:text/html;charset=gb2312")或者header("content-type:text/html;charset=gbk")//如果既有php还包括html代码就只加上下面这段代码
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
1.my.ini里面已经将latin改成gbk;
2.数据库我原先用的是gb2312,现在也改成gbk了
3.这段代码页加了<meta http-equiv="Content-Type" content="text/html; charset=gbk">
没有用啊,求大神再指教
最前面加上
header("content-type:text/html;charset=utf-8");
数据库加上
mysql_query("set names 'utf8'");
这句话应该放在连接数据库后面
$conn = mysql_connect("localhost","root","1234") or die("不能连接数据库服务器:".mysql_connect_errror());
mysql_select_db("messtest",$conn);
mysql_query("setnames 'utf8'",$conn);//使用中文编码;
...
...