Search and Replace using PHP MyAdmin

email

In transferring a WP site from one domain to another (export, import, etc.), some characters were acting up. Smart quotes (e.g. -- " -- and -- " -- instead of just -- " -- between the dashes to show what I mean--ha, I just looked and they don't show up here!) and em-dashes (" — " and not just a dash " - ") were putting odd code into the new site. In WP, I could just see these little diamonds with a question mark in them, but couldn't use search and replace because I couldn't copy and paste the diamond. Solution: get down and dirty with PHP MyAdmin to edit your SQL database. To those I just lost in translation, you're free to leave the room now.

Here's the code to put into an SQL query:

MySQL:
  1. UPDATE wp_posts SET post_content = REPLACE (post_content, '—', '-')

If you don't know what you're doing, please don't even go near this. It's a jungle in there. :-)

Related posts:

  1. Preventing Spam (Java script)
  2. mt :: add photo TO existing entry
  3. PHP List :: Templates
  4. TinyMCE – WYSIWYG Editor
  5. Favicon

About Bradley Charbonneau

I've done the big corporate thing. I've done the creative writer thing. Now I'm happily in the middle. I like to help small businesses who are interested in "working their website before their website works them." I'm also interested in creating beautiful sites with powerful WordPress themes.

5 Responses to Search and Replace using PHP MyAdmin

  1. Jenn September 4, 2007 at 8:22 pm #

    I have to say, I just encountered this issue tonight, and a quick google search brought me to your page. Thank you!

    P.S. Any idea on how to use that function to change those fancy apostrophes to a regular one? I'm stuck at that. :/

  2. Bradley Charbonneau September 5, 2007 at 1:13 pm #

    I think if you can copy and then paste the fancy apostrophes in there, they will be different and you can then replace them. The fancy ones are slanted whereas the plain ones are vertical. Let me know if that worked! -- Bradley

  3. Jenn September 6, 2007 at 10:43 am #

    It didn't, but using the fancy apostrophes as what to find and replacing them with the simple code for an apostrophe, which I believe is "'", worked like a charm!

    Thanks again. I had to transfer a wordpress database containing about six years of continual posting - about 180mb total - and after I had done that, table by table, seeing those weird symbols in place of the quotes and apostrophes made me want to cry!

  4. james tervit November 23, 2009 at 1:36 am #

    I would to thank you for saving me a lot of time, I used your string and it replaced new video coordinates for my new theme

    Affected rows: 25000 (Query took 3.0200 sec)

  5. Orlando February 1, 2010 at 9:58 am #

    this code just saved me weeks of work :) ..
    i used this code to change the tagged from being sperated with black space to being sperated with commos...

    thanks..

Leave a Reply

CommentLuv badge