日期:2014-05-17  浏览次数:20432 次

Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (gbk_chinese_ci,COERCIB
我的php文件设置的是utf8的,数据库连接过程也都是utf8。数据库用的校对编码及字符编码是utf8_unicode_ci。但是我在执行查询句 $sql = "select * from commodity where commodity_name like '%$newstr[0]%' or Sale_Address like '%$newstr[0]%' order by id desc ";时出现了Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (gbk_chinese_ci,COERCIBLE) for operation 'like'的报错。请问谁能猜到怎么回事,该怎么解决?

------解决方案--------------------
肯能输入字符是全角或半角的问题
------解决方案--------------------
$newstr[0]里地内容改变,造成编码不统一,你可以找一种出错的情况,把$sql输出看一下