Articles: Fix Black Diamond with Question Mark in HTML After Switching Servers
Posted by: david on 11/04/2010 - 04:12 PM
Recently I switched the web hosting service provider, and noticed these odd black diamond shaped characters with a question mark in the middle on my web pages. Characters such as the double quote and the copyright symbol are all being replaced by this foul black diamond character with the ? in the center. Doing some research, it seems that happens because you have a character set, or charset, that does not match between the database, web server, and PHP. I use Apache, MySQL, and PHP. Looking at the httpd.conf I noticed:
AddDefaultCharset UTF-8
In PHP.ini I see:
default_charset = "iso-8859-1"
and in my MySQL tables I see "DEFAULT CHARSET=latin1" when I do a "Show Create Table my_table_name".
Not wanting to convert my MySQL data to UTF-8, I edited the line in httpd.conf that showed "AddDefaultCharset UTF-8" to:
AddDefaultCharset On
I also edited the header file for my PHP web pages to show:
Voila- no more weird black diamond character with the question mark inside.