这样的SQL也不行: SELECT id FROM ice_products WHERE `name` LIKE 'sdf%' OR `intro` LIKE 'sdf%' ORDER BY level,id DESC ERROR: #1267 - Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='
从上面可以看出,你的表不是UTF编码 而使用的查询语句是UTF8的 也就是说name列的编码是拉丁 而sdf%的编码是utf8 有二种选择 1.将表编码改成utf8的 2.使用带Collation的SQL语句 SELECT id FROM ice_products WHERE _utf8`name` LIKE 'sdf%' OR _utf8`intro` LIKE 'sdf%' ORDER BY level,id DESC
从哪里看是乱码??你post的是UTF8的数据,保存进最好也使用UTF8来保存
在连接数据库之后设置一下客户端的编码mysql_query("SET NAMES utf8");
你数据库的编码也要是UTF8的,
显示的时候也要指定<meta http-equiv="content-type" content="text/html;charset=utf-8"/>也就是说整个过程都保持一致就没问题了.
SELECT id FROM ice_products WHERE `name` LIKE 'sdf%' OR `intro` LIKE 'sdf%' ORDER BY level,id DESC ERROR:
#1267 - Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='
而使用的查询语句是UTF8的
也就是说name列的编码是拉丁
而sdf%的编码是utf8
有二种选择
1.将表编码改成utf8的
2.使用带Collation的SQL语句
SELECT id FROM ice_products WHERE _utf8`name` LIKE 'sdf%' OR _utf8`intro` LIKE 'sdf%' ORDER BY level,id DESC
ice_berg16(寻梦的稻草人)Thanks.