各位大侠:
    我用php写了一个查找数据库中的一个表,并返回查找结果的文件,执行之后可以得到结果,但是有数据表中有一列存储的是中文内容,无法显示。
    请问这个问题要怎么办。
    数据库使用的是mysql。
    谢谢大家

解决方案 »

  1.   

    编码问题,,
    //前台
    header("content-type:text/html; charset=utf-8");//后台
    mysql_query("set names utf8");是不是uft8就看你的数据库咋个设置的了哈
      

  2.   

    mysql_query("set names '你的数据库编码'");
    还有输出的时候用header指定一下字符集。。反正统一编码就行了。
      

  3.   

    你的php文件也要使用utf8。 再加上1楼的,基本就解决问题了
      

  4.   

    谢谢您,但是还是不行,把代码贴出来,帮忙看看
    <?php
    header("Content-Type:text/html;charset=utf-8"); $link=mysql_connect("localhost","root","root"); mysql_select_db('ppcdn',$link)or die('不能选定数据库ppcdn:'.mysql_error());
    mysql_query("set name as utf8");
    $result=mysql_query("select * From domain_tbl");
    echo '<table align="center"width="80%"border="1">';
    echo '<caption><h1>domain_tbl</h1></caption>';
            echo '<th>domain_id</th><th>domain_name</th><th>domain_desc</th><th>parent_id</th>           <th>is_detail</th>';
    while($row=mysql_fetch_row($result))
    {
    echo "<tr>";
    foreach($row as $data)
    {
    echo '<td>'.$data.'</td>';
    }
    echo '</tr>';
    }
    echo '</table>';
    mysql_free_result($result);
    mysql_close($link);
    ?>
    数据库的编码是utf8_general_ci
      

  5.   

    先检查在数据库中是否乱码。 还有确认你的程序也是用utf-8。
      

  6.   

    数据库中不是乱码,怎么看程序的编码格式啊,我刚接触php 菜鸟一个
      

  7.   

    mysql_query("set name as utf8");应该是mysql_query("set name 'utf8'");同时文件也保存为utf-8格式的
      

  8.   


    mysql_query("set name as utf8");
    改成
    mysql_query("SET NAMES 'utf8'");
      

  9.   


    you are talking about American movie.
      

  10.   

    多谢大家帮忙,问题解决,要使用mysql_query("SET NAMES UTF8");