wamp+PHP有关问题

WBOY
Release: 2016-06-13 13:52:37
Original
736 people have browsed it

wamp+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文件代码:
$conn = @ mysql_connect("localhost", "root", "") ;
mysql_select_db("new", $conn);
mysql_query("set names 'GBK'"); //使用GBK中文编码;
?>

------解决方案--------------------

mysql_query("set names 'GBK'");

您觉得合适吗?
------解决方案--------------------

mysql_query("set names 'GBK'"); //使用GBK中文编码;
页面编码与数据库编码要一致吧。

------解决方案--------------------
建议以你数据库中的编码为主。 两者统一即可。。
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
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!