简体   繁体   中英

PHP & Illegal mix of collations in MySql dump file

I wrote a PHP script to harvest some data that I want to enter into a database. This includes user's usernames that need to be entered, some users chose usernames with upside down text, ie, 'uıɯpɐ'

I get a collation error when I use that username in a WHERE clause, is there a way for php to sanitize that before going into the database to avoid this?

#1267 - Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '=' 

The way the script is set up I don't have much of a choice but to use the username in the where clause.

uıɯpɐ comes from someone messing with your head. It is characters scrounged from various UTF-8 charsets to make what looks like an upside down admin . But note that he used a "dotless i" (a Turkish character) to sort of create the upside down i .

You should change any columns that need to have arbitrary characters from latin1 to utf8mb4 . If you still have collation errors, we can discuss what else needs changing. I can't be more specific without seeing the statement causing the error, SHOW CREATE TABLE and the connection parameters.

More UTF-8 tips: Trouble with UTF-8 characters; what I see is not what I stored

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM