PDO + MySQL and broken UTF-8 encoding

QuestionsPDO + MySQL and broken UTF-8 encoding
sethbeckerman5 Staff asked 15 years ago

I use the PDO library with a MySQL database in PHP, but if I insert any data encoded in UTF-8, like Arabic words, it’s inserted into the database, but as .

In my own framework, after I create the PDO connection, I send two queries – and . It still doesn’t work.

Example:

Workaround: Use the function to convert data before inserting it to the database, and use to decode it after fetching. This is how I do it now.


View on Stack Overflow