广告联盟网

 找回密码
 注册
查看: 982|回复: 15
打印 上一主题 下一主题

MYSQL中文乱码如何处理?

[复制链接]
跳转到指定楼层
1#
发表于 2007-7-14 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
`name` VARCHAR( 20 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,<br />`code` VARCHAR( 6 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL ,<br />`cat` VARCHAR( 1 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL)&quot;;<br /><br />`name` VARCHAR( 20 ) CHARACTER SET utf8 NOT NULL,<br />`code` VARCHAR( 6 ) CHARACTER SET utf8 NOT NULL ,<br />`cat` VARCHAR( 1 ) CHARACTER SET utf8 NOT NULL)&quot;;<br /><br /><br />`name` VARCHAR( 20 ) CHARACTER SET gb2312 NOT NULL,<br />`code` VARCHAR( 6 ) CHARACTER SET gb2312 NOT NULL ,<br />`cat` VARCHAR( 1 ) CHARACTER SET gb2312 NOT NULL)&quot;;<br /><br />都不行啊 <br /><br />帮帮忙谢谢<br /><br />`name` VARCHAR( 20 ) CHARACTER SET gb2312 COLLATE gb2312_bin NOT NULL,<br />`code` VARCHAR( 6 ) CHARACTER SET gb2312 COLLATE gb2312_bin NOT NULL ,<br />`cat` VARCHAR( 1 ) CHARACTER SET gb2312 COLLATE gb2312_bin NOT NULL)&quot;;<br /><br />不行<br /><br />[<i> 本帖最后由 mjoshua 于 2007-7-14 20:55 编辑 </i>]
2#
发表于 2007-7-14 | 只看该作者
连接数据后执行mysql_query(&quot;set names utf8&quot;);
3#
 楼主| 发表于 2007-7-14 | 只看该作者
<br><br><div class="msgbody"><div class="msgheader">QUOTE:</div><div class="msgborder">原帖由 <i>网鬼</i> 于 2007-7-14 20:52 发表 <a href="http://www.im286.com/redirect.php?goto=findpost&amp;pid=20547185&amp;ptid=2067129" target="_blank"><img src="http://www.im286.com/images/common/back.gif" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://www.im286.com/images/common/back.gif');}" onmousewheel="return imgzoom(this);" alt="" /></a><br />连接数据后执行mysql_query(&quot;set names utf8&quot;); </div></div><br>这有什么用?我直接在创建的时候,就指定name 为uft8了<br />都不行,连接之后再指定
4#
发表于 2007-7-14 | 只看该作者
在输出页面直接强制使用UFT-8编码
5#
 楼主| 发表于 2007-7-14 | 只看该作者
可是我要拿数据库里面的字符串还要进行一些对比,乱码,没法对比啊<br />还有就是用了binary数据类型之后,在数据库里显示是中文,可是明明视觉上是相同的字,它对比的就是错误
6#
发表于 2007-7-14 | 只看该作者
技术贴。两种方法<br />@mysql_query(&quot;set names 'gbk'&quot;); <br /><br />iconv($str,'gbk','utf8')
7#
发表于 2007-7-14 | 只看该作者
<br><br><div class="msgbody"><div class="msgheader">QUOTE:</div><div class="msgborder">原帖由 <i>mjoshua</i> 于 2007-7-14 21:03 发表 <a href="http://www.im286.com/redirect.php?goto=findpost&amp;pid=20547333&amp;ptid=2067129" target="_blank"><img src="http://www.im286.com/images/common/back.gif" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://www.im286.com/images/common/back.gif');}" onmousewheel="return imgzoom(this);" alt="" /></a><br />可是我要拿数据库里面的字符串还要进行一些对比,乱码,没法对比啊<br />还有就是用了binary数据类型之后,在数据库里显示是中文,可是明明视觉上是相同的字,它对比的就是错误 </div></div><br><img src="images/smilies/ohh.gif" smilieid="19" border="0" alt="" /> 谁喊你用binary数据类型啊~~该惨(风凉话)
8#
发表于 2007-7-14 | 只看该作者
9#
 楼主| 发表于 2007-7-14 | 只看该作者
对了,这是采集中文页面碰到的问题,要怎么处理这些?刚学PHP
10#
 楼主| 发表于 2007-7-14 | 只看该作者
<br><br><div class="msgbody"><div class="msgheader">QUOTE:</div><div class="msgborder">原帖由 <i>yangbo254</i> 于 2007-7-14 21:08 发表 <a href="http://www.im286.com/redirect.php?goto=findpost&amp;pid=20547430&amp;ptid=2067129" target="_blank"><img src="http://www.im286.com/images/common/back.gif" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://www.im286.com/images/common/back.gif');}" onmousewheel="return imgzoom(this);" alt="" /></a><br /><br /><img src="images/smilies/ohh.gif" smilieid="19" border="0" alt="" /> 谁喊你用binary数据类型啊~~该惨(风凉话) </div></div><br>在网上找中文乱码处理方法的时候看到的
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|广告联盟网  

GMT, 2024-11-28 , Processed in 0.072583 second(s), 19 queries .

Powered by Discuz! X3.2

© 2005-2021 www.ggads.com GGADS 广告联盟网

快速回复 返回顶部 返回列表