刚留了一条言为什么显示不到中文字符的?
连接数据库的代码是如下:
<?php
$link=mysql_connect('localhost','root','root')
or die ('数据库链接出错:'.mysql_error());
mysql_query("set names = 'GBK'");
mysql_select_db('guestbook');?>
字段格式:username   varchar(16)   gbk_chinese_ci    否  
服务器:MySQL 字符集:  UTF-8 Unicode (utf8) 
        MySQL 连接校对:utf8_general_ci

解决方案 »

  1.   

    刚留了一条言为什么显示不到中文字符的?
    插入数据库前请将字符串转码,iconv(),转成你数据库的格式
      

  2.   

    插入数据库前转好码(最好和你的数据库统一)
    取数据时,在显示数据时候将数据转成需要的类型,如php页面编码类型
    同统一数据库、php页面、模板页面、浏览器显示 的编码以上操作是常用的避免乱码的方法还有mysql_query("set names = 'GBK'");没用过,不知道管不管用,不过哪有mysql_query("set names GBK")好啊,是不是还比你的少些几个字符呢,是吧
      

  3.   

    是国外的空间,转码?iconv()可以举个例子吗?
      

  4.   

    会不会是 你 PHP页面字符集设置的有问题啊 ?
    header('Content-Type:text/html;charset=GBK');
      

  5.   

    数据库显示正常,就是输出的时候中文为???<?php
    require('common.php');
    $result = mysql_query("SELECT * FROM gb_content order by id desc");//查询数据while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {// 取一条数据
    ?>
    <table width="700" border="0" cellspacing="0" cellpadding="0" class="tb">
      <tr>
        <td class="bg"><b>[<?php echo htmlentities($row['username'],ENT_COMPAT,'utf-8') ?>]</b> 发表于:<?php echo htmlentities($row['insert_time'],ENT_COMPAT,'utf-8') ?></td>
      </tr>
      <tr>
        <td><?php echo htmlentities($row['content'],ENT_COMPAT,'utf-8') ?></td>
      </tr>
      <tr>
        <td align="right"><a href="edit.php?id=<?php echo $row['id'] ?>">修改</a> <a href="delete.php?id=<?php echo $row['id'] ?>">删除</a></td>
      </tr>
    </table>
    <?php
      

  6.   

    字符集设置的原因,按下贴中的方法贴出你的检查结果。
    http://blog.csdn.net/ACMAIN_CHM/archive/2009/05/12/4174186.aspx
    MySQL 中文显示乱码
      

  7.   

    查看网页编码设置 set names utf8