当前位置:编程学习 > php >>

求助PHP大神...thinkphp插入数据库乱码

我用thinkphp向mysql数据库插入一组数据但是中文字符全是乱码:
public function insert(){    header("Content-Type:text/html; charset=utf-8");    $Dao = M("User");// 实例化模型类         // 数据对象赋值    $Dao->username = "红一样";    $Dao->password = md5("123456");    $Dao->email = "12345@163.com";    $Dao->regdate = time();
    // 写入数据mysql_query("set names utf8");    if($lastInsId = $Dao->add()){               echo "插入数据 id 为:$lastInsId";    } else {        $this->error('数据写入错误!');    }}
追问:我的数据一点问题也没有
是本来就有的数据
php文件时utf-8
数据库也是utf-8
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,