我在网上找了好多方法
诸如:mysql_query("set names 'gbk'") mysql_query("set names utf8") 修改php.ini配置文件等等 都没用额我的数据库是utf-8的所有文件也是utf-8的能正常入库,就是里面的中文全成乱码了望高人指点,谢谢

解决方案 »

  1.   


    我用phpmyadmin进入数据库浏览看的额
      

  2.   

    入库也没进行处理额 
    代码如下:<?php 
    include("conn.php"); 
    header('Content-Type: text/html; charset=UTF-8');
    $man=$_POST["man"];
    $tel=$_POST["tel"];
    $add=$_POST["add"];
    $fax=$_POST["fax"];
    $content=$_POST["content"];
    $datex=date("Y/m/d");
    if (strlen($man)<=0 ){
    echo "<script>alert('请输入您的大名');history.go(-1)</script>";
    exit;
    }
    if (strlen($tel)<=0){
    echo "<script>alert('请输入您的联系方式');history.go(-1)</script>";
    exit;
    }
    if (strlen($content)<=0){
    echo "<script>alert('请输入留言内容');history.go(-1)</script>";
    exit;
    }
    if (strlen($content)<=10){
    echo "<script>alert('您输入的留言内容过短,最少十个字。');history.go(-1)</script>";
    exit;
    }
    if (strlen($content)>=300){
    echo "<script>alert('您输入的留言内容长,最多300字。');history.go(-1)</script>";
    exit;
    }
    mysql_select_db("hellodate",$con);
    $sql="INSERT INTO message
    VALUES ('','$man','$tel','$add','$fax','$datex','$content')";
    if(!mysql_query($sql,$con))
      {
      die('Error: ' . mysql_error());
      mysql_close($con);
      exit;
      }
    else{  
    mysql_close($con);
    echo "<script>alert('恭喜您,留言成功');location.href='index.php'</script>";
    exit;
    }
    ?>
      

  3.   

    那就是你的数据库本身不是utf-8
      

  4.   


    这我怎么查额 显示的字符集是utf-8 哦文件我查过了 是utf8额
      

  5.   

    检查你的phpmyadmin是否是用utf8的编码连接的
      

  6.   

    如果用 utf-8 编码的 phpmyadmin 观察到的内容是乱码,则表示你库中的数据并非 utf8 编码的你的代码中并没有出现 mysql_query("set names utf8"),所以你的数据并不是按 utf-8 编码入库的mysql_query("set names utf8") 表示其后的数据是 utf-8 的
    但并不保证之前的数据也是 utf-8 编码的
      

  7.   

    我刚检查了下conn文件也是utf8编码连接的也是 utf8 unicode ci数据库编码也是 utf8 unicode ci
    那段代码中我加入了 mysql_query("set names utf8") 提交之后还是乱码额
      

  8.   

    conn文件是utf8编码
    那段代码中我加入了mysql_query("set names utf8"); 
    数据库的编码是utf8 unicode ci
    数据表也是 utf8 unicode ci可是还是乱码额
      

  9.   

    确保php文件是utf-8的,在写入数据之前;set_names('utf-8');总的你要确保你的 页面编码,文件编码,和写入数据库的信息的编码一致就不会出现乱码了