New WordPress admin design
September 9th, 2006Installing WordPress & Fixing question marks (???) in content
August 9th, 2006Just a note to all those people out there who might be wanting to use WordPress:
Make sure when you are setting up your WordPress database in MySQL that you choose utf8 as the encoding type.
I, unfortunately found out the hard way that not encoding it as utf8 is a major pain. I spent 4 days attempting to solve a problem that I thought was caused by a WYSIWYG editor for WordPress when it was simply the database encoding. When WordPress writes posts or comments to the database, it writes them in its preferred encoding type (utf8). But if the database is not encoded in utf8, it does not know how to treat the utf8 characters. Therefore, you get weird characters in your browser because the browser does not know how to handle the utf8 characters that have been changed over to who knows what in the database.
How to fix it if it happens to you:
If you're one of the unlucky ones, don't despair!?? It can be fixed, and it isn't too difficult, but it is a bit of a pain. Here's how.
- Back up your database. In fact, do it twice because two is better than one!
- Make a second (or third) backup but this time export each table separately. I used phpMyAdmin to export each table as a file.
- Open up each separate table dump and save it with a character encoding of utf8. I use BBedit. In BBedit, you can change the encoding by going to File –> Save As… When the finder comes up prompting for where to save it, click on Options. You can then change the encoding to utf8 from the drop down list. The reason you save the SQL dump to utf8 is that doing so will convert all the symbols back to the correct encoding for utf8 and get rid of the question marks in your existing content.
- Look through the sql dump for the encoding that it uses (in my case it was ascii). It should be somewhere in the CREATE TABLE statement, usually toward the end of the statement. Mine looked like this: ENGINE=MyISAM DEFAULT CHARSET=ascii AUTO_INCREMENT=32 ; I changed the CHARSET=ascii to CHARSET=utf8. Save your file.
- After you've done the above to all the tables, create a new database. Why create a new one rather than importing into the old one? The main reason is that if you have problems, you can easily just point back to the old database while you sort them out on the new database.
- Import all the data you've converted to utf8 into the new database.
- After you've imported all the data, change your wp-config.php file to point at the new database.
- Congrats. You're done.
- Now, go back to your site and everything should be fixed. If there were problems importing the data or you have data missing, you can always change the config file to point back to your old database while you re-export and fix any problems.
Problems? Questions? Suggestions? Let me know.




