简体   繁体   中英

PHP / MySQL character encoding incompatible?

I'm having what I believe to be an encoding issue with a mysql connection from php, print shows the query fine, and if I run the printed query on phpmyadmin, it returns results, but comes back empty from my script, does anyone know where can I look to figure out what's going on?

this is the offending query:

SELECT id FROM categories WHERE name_es = 'Pédagogie / Enseignement' OR name_fr = 'Pédagogie / Enseignement'

the same query with different values for the WHERE clause (values without é or other non-english characters) work fine, that's why I think it's encoding-related.

Retrieving and printing these data from the database is working just fine

Thanks

[EDIT: I think the problem might be that I'm grabbing the text that I'm querying from an uploaded file as writing the exact same text into a search text input I have which generates the exact same query works fine]

[RESOLVED: This was apparently caused by a space character encoded weirdly. It printed fine, but a double-encoded print showed difference between the queries I talk about in the [edit]]

Try mysql_set_charset to see if it works. Also check 'MySQL connection collation' in phpMyAdmin for your database.

This was apparently caused by differently encoded whitespace.

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