Illegal mix of collations in mysql + codeigniter 在mysql和codeigniter中出现了字符集的非法混合。

22 浏览
0 Comments

Illegal mix of collations in mysql + codeigniter 在mysql和codeigniter中出现了字符集的非法混合。

我正在使用CodeIgniter框架实现一个查询。

在实现下面的查询时,我总是遇到这个错误:“Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='”:

 $customer_name = "orduña's";
 $escape_string = mysql_escape_string($customer_name);
 $sql = "SELECT* FROM raw_customer WHERE customer_name ='$escape_string'";
 $query = $this->db->query($sql);
 return $query->row_array();

我非常确定我的数据库已经设置为utf8字符集和utf8_general_ci排序规则,甚至尝试了utf8_unicode_ci。

我也非常确定我的数据库表也一致使用utf8。

我也非常确定头部标签中已经实现了utf8的元标签。

0
0 Comments

当在MySQL和CodeIgniter中出现"illegal mix of collations"的错误时,可能是由于连接和表的字符集和校对规则不匹配所导致的。

解决方法是将连接和表的字符集和校对规则都设置为相同的值,比如将它们都设置为"latin1"和"latin1_swedish_ci"。

以下是一个示例查询,可以作为解决此问题的参考:

$sql = "SELECT * FROM raw_customer WHERE customer_name = (_utf8 '$escape_string')";

0