14
Jun

Fix odd characters in Wordpress posts

I noticed recently that my Wordpress data had some funky characters in almost every post: Examples: ’ … After browsing through the posts it looks like those characters represent things like quotations, dashes and double periods. I read through various forums that said this is caused due to the encoding and collation, however after following the recommendations of sites like http://www.mydigitallife.info/2007/0...to-version-22/ I was still unable to get rid of the huge amount of garbled characters. Ultimately, I spent some time mapping each set of characters to the appropriate one (quotes, commas, etc...) and built a php script to basically: 1. Loop through every post in the Wordpress database 2. Find and replace all the garbled characters 3. Re-insert the data I have attached the script below (very simple) in case others find this the only way to cleanse out this character issue. One other thing I should mention - this only works if the garbled characters are actually garbled in the database - if the issue is simply how your browser is rendering the text, and not how the strings are actually stored in the database, then this wont help you. Although feel free to give it a shot. One other thing - you may need to add additional characters to replace in the script. It should be self explanatory how based on what I have presented already. If you need help. simply post in here.

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'dbUserNameHere'@'localhost' (using password: YES) in /home1/cjfaycom/public_html/wp-content/plugins/exec-php/includes/runtime.php(42) : eval()'d code on line 44
Error connecting to mysql