I’m using Amazon’s RDS, and I’m having difficulty reading utf data from the DB. The results are shown as non-utf characters and hence with utf-8 encoding in the db they show up as bad characters.
The DB was transferred from another MySQL database (not Amazon RDS) and when the code communicates with that database everything is fine.
I checked the Character Set, and Collates on all tables, and the DB itself they are all UTF-8 and utf_general_ci
The pages are using utf-8 encoding like this
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
I also tried passing this query “SET NAMES utf8”, still didn’t help.
I noticed someone else has had the same problem with RDS
Can't store UTF-8 in RDS despite setting up new Parameter Group using Rails on Heroku
And the solution given to them was to specify the character set in the connection string, that solution apparently worked for rails, but in PHP I don’t think there is such a thing as connection string.
This is how I connect to mysql
mysqli_connect($this->host, $this->login, $this->pw, $this->database)
Also if I change the data type of those columns to binary data types such as BLOB they will work properly.
What you’re looking for instead of a connection string is most likely mysqli::set_charset() which will change your default client character set;