wamp+PHP问题
一个简单的留言功能,为啥在网页上输入中文,在数据库了就变乱码,求助!!!!!
这是页面和链接数据库代码:
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″ />
<?php
include (‘conn.php’);
if($_POST[‘sub’]){
$ghj=”insert into message (id,user,title,content,lastdate) “.
“value(”,’$_POST[user]’,’$_POST[title]’,’$_POST[content]’,now())”;
mysql_query($ghj);
echo “成功”;
}
?>
用户:
标题:
内容:
这是conn.php文件代码:
<?php
$conn = @ mysql_connect(“localhost”, “root”, “”) ;
mysql_select_db(“new”, $conn);
mysql_query(“set names ‘GBK'”); //使用GBK中文编码;
?>
——解决方案——————–
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″ />
mysql_query(“set names ‘GBK'”);
您觉得合适吗?
—9来源gaodai#ma#com搞@代~码$网搞gaodaima代码—-解决方案——————–
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″ />
mysql_query(“set names ‘GBK'”); //使用GBK中文编码;
页面编码与数据库编码要一致吧。
——解决方案——————–
建议以你数据库中的编码为主。 两者统一即可。。