mysql控制台安插汉字无乱码,php插入就乱码

WBOY
Release: 2016-06-13 11:58:50
Original
945 people have browsed it

mysql控制台插入汉字无乱码,php插入就乱码;
header("content-type:text/html;charset=utf-8");
$title   =$_POST['f_title'];
$content =$_POST['f_content'];
//连接数据库
$link=mysql_connect('localhost','root','');
//选择数据库
mysql_select_db('bbs',$link);
//设置字符集
mysql_query("set names utf8");
//生成sql语句
$sql="insert into bss_info (title,content,add_time) values ('$title','$content',now())";
//执行sql语句
$rs=mysql_query($sql);
//生成sql错误提示
echo mysql_error();
//页面信息提示
if($rs)
{
echo "信息添加成功!";
}else 
{
echo "信息添加失败!";
}
?>
------解决方案--------------------
1、表是utf8编码吗
2、文件编码是utf-8编码吗

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