一个简单的留言功能,为啥在网页上输入中文,在数据库了就变乱码,求助!!!!!这是页面和链接数据库代码:<head><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 "成功";
}?>
<form action="index.php" method="post">
用户:<input type="text" size="10" name="user"/><br>
标题:<input type="text" name="title"/><br/>
内容:<textarea name="content"></textarea><br/>
<input type="submit" name="sub" value="发布留言"/></form></head>
这是conn.php文件代码:
<?php
$conn = @ mysql_connect("localhost", "root", "") ;
mysql_select_db("new", $conn);
mysql_query("set names 'GBK'"); //使用GBK中文编码;
?>

解决方案 »

  1.   

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    mysql_query("set names 'GBK'");您觉得合适吗?
      

  2.   

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    mysql_query("set names 'GBK'"); //使用GBK中文编码;
    页面编码与数据库编码要一致吧。
      

  3.   

    把<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    换成<meta http-equiv="Content-Type" content="text/html; charset=GBK" />吗?