Lacrymology
Lacrymology

Reputation: 2259

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]]

Upvotes: 0

Views: 343

Answers (2)

Lacrymology
Lacrymology

Reputation: 2259

This was apparently caused by differently encoded whitespace.

Upvotes: 0

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

Upvotes: 1

Related Questions