I have an old database on a MySQL 4.1 server, the db contains some user inputted content, I have copied this database to a new MySQL 5 server and when I view a page where the content is printed, I see the black diamond character with question mark in the middle. This only shows on the new server.
If I add this header to the page, the diamond no longer shows:
header('Content-Type: text/html; charset=iso-8859-1');
If I take out that header, then the server sends a default header which looks like below, and the diamond re-appears
Content-Type: text/html; charset=UTF8
How can I resolve this in the db (e.g. some sort of conversion on the tables), so that I don’t have to put this header in all of my pages?
More info: I used a mysqldump to export the database from the old server, then used the CentOS mysql command line to import it. I have also tried exporting using phpMyAdmin but it’s the same result.
Edit:
Looking at my mysqldump file, I can see that all of the CREATE TABLE statements have the charset = Latin1, so I think what I’m looking for is a way to export the database in UTF8 instead. I have tried adding this option to mysqldump but it didn’t have any effect, the dump still shows Latin1:
–default-character-set=utf8
Try setting the charset after connecting to your database: