刚留了一条言为什么显示不到中文字符的?
连接数据库的代码是如下:
<?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
连接数据库的代码是如下:
<?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
解决方案 »
- 关于函数__construct的问题
- 【求救】关于linux下Smarty写缓存文件的问题
- isset($_GET['login'])
- 关于正则表达式的解释?
- PHP+FLASH
- 关于在smarty 模板里的JavaScript脚本变量接受附值问题
- 那个高手 能看懂这个程序段?
- 在PHP中使用socket的几个问题(接收的最大字节数如何设置,如何判断接收完成)
- 哪个知道如google等搜索引擎,如何能搜到数据库的信息呢?
- 好想在php做斑竹阿,大家有没有觉得我们喜爱的php版好冷清!(申请做版主)
- 在ubuntu配置完php和apache后出错访问出错了
- preg_replace正则/e参数的特殊用法求教
插入数据库前请将字符串转码,iconv(),转成你数据库的格式
取数据时,在显示数据时候将数据转成需要的类型,如php页面编码类型
同统一数据库、php页面、模板页面、浏览器显示 的编码以上操作是常用的避免乱码的方法还有mysql_query("set names = 'GBK'");没用过,不知道管不管用,不过哪有mysql_query("set names GBK")好啊,是不是还比你的少些几个字符呢,是吧
header('Content-Type:text/html;charset=GBK');
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
http://blog.csdn.net/ACMAIN_CHM/archive/2009/05/12/4174186.aspx
MySQL 中文显示乱码