From pMachine Pro 2.3 to WordPress 1.5

Posted by Pierre Igot in: Blogging
July 16th, 2005 • 11:54 am

In spite of my earlier concerns, I was actually able to migrate from pMachine to WordPress relatively easily. Since, as far as I know, this procedure is not really documented anywhere on the web, I thought I’d share a few comments about the process, in case it might help out other people in a similar situation.

The first challenge was to identify the appropriate tool to do this. WordPress comes with a number of built-in importers, but does not include one for pMachine. After searching through the WordPress forums, I was able to find this thread, which discusses the issue and includes a solution.

The solution is a PHP script that is available on this page. The author of the script doesn’t actually provide much information, so here goes.

First, you need to go to his page with the code and cut and paste the code into a blank text file (with TextEdit for example). Save this file as “import-pmachine23-0.3.php“. Before you close it, however, you will need to edit it to remove a function that is redundant and is already included elsewhere in WordPress. As one of the readers on the thread notes, if you leave it, you’ll get the following error message when trying to run the importer:

Cannot redeclare sanitize_title_with_dashes() (previously declared in /Users/francis/Sites/wordpress/wp-includes/functions-formatting.php:87)

So look for the function “sanitize_title_with_dashes” in the PHP file and select it and delete it. Make sure you only select the function itself, i.e. this portion of the code:

 function sanitize_title_with_dashes($title) {
    $title = remove_accents($title);
    $title = strtolower($title);
    $title = preg_replace('/&.+?;/', '', $title); // kill entities
    $title = preg_replace('/[^a-z0-9 _-]/', '', $title);
    $title = preg_replace('/\s+/', ' ', $title);
    $title = str_replace(' ', '-', $title);
    $title = preg_replace('|-+|', '-', $title);
    $title = trim($title, '-'); // remove trailing dashes
    return $title;
  }

Once you’ve deleted this portion, save the PHP file somewhere on your hard drive.

The next step is to install WordPress. I chose to install WordPress 1.2, because, based on the information in the thread, that was the version of WordPress that the script was designed for. I figured I would import into WordPress 1.2, and then upgrade WordPress 1.2 to WordPress 1.5.

I discovered later on, however, that the script appears to work fine directly with WordPress 1.5 — which is good, since WordPress 1.2 doesn’t appear to be available as a download on the WordPress web site any longer. (I had kept a local copy of version 1.2.)

You need to make sure that you install WordPress in the exact same directory as the one in which pMachine is installed. This is not really a problem, as the two packages don’t have any file names in common. If, however, you already have a file called “index.php” in your pMachine folder (which is possible in some situations), then just rename it temporarily.

I won’t reproduce the steps required to install WordPress here. They are clearly documented on the WordPress site. You can use the same MySQL database as the one used by pMachine, since the tables created by WordPress all start with the “wp_” prefix and will simply be added to the database without interfering with your pMachine tables. Make sure you have completed the installation and actually have an admin login and password for your WordPress set-up.

After that, log in and, in the WordPress control panel, delete the existing “Hello world!” blog entry that’s included there by the WordPress as an example. (I am not sure this step is required, but I did it myself, just to be on the safe site. I didn’t want two posts with the same ID.)

Basically, you now have an empty WordPress shell, and you are ready to run the importer. In order to do so, first upload the “import-pmachine23-0.3.php” created earlier on to the “wp-admin” folder on your web site, which already contains import files for b2, Blogger, GreyMatter, MovableType, etc. After you’ve done that, just type the following URL in your browser:

http://www.yoursite.com/wp-admin/import-pmachine23-0.3.php

(If your pMachine and WordPress installations are somewhere inside a sub-folder on your web site, adjust the URL accordingly.)

Press Return. This will execute the PHP script on your server. A few lines of text will appear indicating the completion of the various steps of the importing process. It will not take long, unless you have a very large blog. My pMachine blog had 1,600 entries and 2,400 comments, and the process only took a few seconds.

After that, you can immediately test your site to see if your entries are there in WordPress. If all goes according to plan, they will be there. The blog entries will have the same ID as the one that they had in pMachine. All your user registrations will be there as well, with registered pMachine users registered by default as level 0 users in WordPress (which allows them to post comments). Your user comments will be there as well, except that they will no longer have the same ID as the one they had in pMachine, which is not really a problem as you normally don’t have anything that refers to a user comment by its ID anywhere on your site.

Basically after that you are good to go. You can apply the WordPress 1.5 upgrade on top of your WordPress 1.2 install.

There are a few things to note, however. One is that, if the character set used in pMachine is not the same as the one in WordPress, you will have problems with non-ASCII characters, such as accented characters and some punctuation marks. For example, in my case, pMachine was using ISO-Latin1 and WordPress was using UTF-8. I wanted to migrate from ISO-Latin1 to UTF-8, so this was intentional. But it meant that my accented characters would be screwed. There is a way around this, however.

After you’ve imported your pMachine entries into WordPress, use a tool such as phpMyAdmin to create a “dump” of your entire WordPress database. (If you still have the pMachine tables in the same database as the WordPress tables, select only the tables starting with “wp_” in your database and export those only.) phpMyAdmin is not the most user-friendly tool I’ve ever used, but once you’ve figured out how it works, it’s pretty straightforward. If you are wondering which options to use for the export process, don’t worry. In my experience, the default settings work just fine.

Once you have a dump of your entire WordPress database, open it with a text editor such as BBEdit. (The dump is simply a very large text file with the entire contents of your blog — entries, users, comments, etc. — in the form of SQL instructions that can be used to recreate your database on a server running MySQL from scratch.) Scroll down the dump text file to a place where you have text with non-ASCII characters. See if they look OK there. If they don’t, use BBEdit’s “Reopen Using Encoding” command to reopen the dump with the appropriate character set encoding setting.

Once the accented characters look as expected, simply save the dump as a new text file with the intended character set in WordPress. For example, my dump was in ISO-Latin1. I simply saved it as a text file encoded in UTF-8 (with no BOM) with BBEdit’s options in the “Save As” dialog box.

While you are at it, you might want to clean up your entries with a few Find/Replace operations in BBEdit. For example, until now in my pMachine blog entries encoded in ISO-Latin1, I had used a double dash (–) as a substitute for the em dash (—). Now that my blog was in UTF-8, I was able to change the double dashes back to real em dashes. (As far as I can tell, the double dash isn’t used for anything else in the dump file.) Similarly, I had used three consecutive periods (…) as a substitute for the ellipsis character (…). I did a batch Find/Replace operation for this too. There is no need to update apostrophes and quotation marks, however. By default WordPress changes straight ones with curly (typographic) ones on the fly when displaying blog entries. It’s a good thing too, because quotation marks and apostrophes are used for all kinds of things in the dump text file and replacing the right ones with curly ones without affecting the other ones would require a fair amount of grep magic.

(If your blog entries contain a fair number of cross references, you will also want to replace all the URLs still referring to the pMachine entries with URLs referring to the corresponding entries in WordPress. Since the entries have the same post ID in pMachine and in WordPress, it’s not a very difficult process, as long as you are willing and able to use some grep. I will discuss this in more detail in another post coming soon.)

After all that, all that remains to do is to upload the cleaned up dump file back to the server, use phpMyAdmin to drop (i.e. delete) the existing WordPress tables in the database, and restore the WordPress database from the new dump file now cleaned up and properly encoded. (There are probably several ways to restore a database from a dump file. I simply used the mysql command in the command-line interface on my server.)

The next phase is to customize the look of your WordPress pages to make them match your personal taste. (WordPress comes with a few built-in themes and there are lots of other themes available on the web.) But basically when it comes to your blog’s content, you’re done.

I should note that I did encounter a few snags that made the process a bit more stressful than what’s described above. The main one was that, after importing the pMachine database tables into WordPress, I had all kinds of fictitious comments in my wp_comments table (which contains user comments). I was also missing the last 400 or so of my actual comments. In other words, of the 2,400 user comments in my pMachine database, in the WordPress database I had the first 2,000 comments, followed by about 500 comments consisting of bits taken from the text of my blog entries themselves, attributed to various users and with erroneous time stamps, etc.

I don’t know if it’s a flaw in the PHP script. But it might happen to you. What I ended up doing was to repeat the process of importing the pMachine entries into WordPress, this time going directly from pMachine 2.3 to WordPress 1.5. (That’s when I discovered that this worked just fine, and there was no need to go through WordPress 1.2 first.) After I did that, I had all 2,400 of my actual comments, but still followed by about 500 fictitious comments. I then simply deleted the 500 fictitious ones, and things seemed to work fine after that.

I also experienced a number of problems apparently related to caching issues, either in my own browser software (Safari, Camino) or on my provider’s server. Sometimes things that I thought I had corrected appeared not to have been corrected, but it was only because I was still viewing an old web page in a cache. If this happens to you, before concluding that your corrections didn’t work, make sure you’ve flushed all your caches and also that you are not viewing old cached page from your provider’s servers.

I must also stress, in conclusion, that the above description is not a full-blown tutorial and that I’ve skipped a number of small steps. I simply do not have to time to describe the process in full for an inexperienced user. If you are not comfortable using phpMyAdmin and the occasional command-line command, and if you have no existing experience at all with WordPress, PHP, etc., you might find the above wanting. But if you are a reasonably experienced blog author like myself, who simply finds himself stuck with a discontinued blogging system and wants to switch to something more modern and user-friendly, like the free (open source) WordPress, then this might help.


19 Responses to “From pMachine Pro 2.3 to WordPress 1.5”

  1. gisrs.net says:

    I’m running my blog here – http://www.gisrs.net/blog/ – and I was wondering if these instructions & script work for converting my pMachine FREE 2.3 to WordPress 1.5?

    Please reply OR email me, thanx kindly.

  2. Pierre Igot says:

    I am afraid I have no experience with running the import script with pMachine Free — but there’s really no harm in trying, since all the script does is that it creates a new set of tables with the “wp_” prefix in your MySQL database. At worst, the tables won’t be any good and you can just delete them with phpMyAdmin.

    So yeah, these instructions might work just fine. Give it a try! And if it works, don’t forget to post a feedback note on the WordPress forum thread for this tool.

    Good luck!

  3. gisrs.net says:

    Ok…here we go (insert cracking of knuckles, stretching of arm muscles).

    Parse error: parse error, unexpected T_STRING in /homepages/26/d95181371/htdocs/blog/import-pmachine23-0.3.php on line 29

    AAaaaahhhh!! (insert bulging eyes, heavy breathing, scratching head)
    -Maybe i’ll try upgrading to pMachine Pro 2.4 first then running the script again ;-8

  4. Pierre Igot says:

    Eeek :-/. Yup, obviously the import script is designed for pMachine Pro. Unless you can get help from the author of the script to adapt it to pMachine Free, upgrading to pMachine Pro 2.4 is probably the best option.

  5. uno says:

    I keep getting errors like this when trying to import my comments with this script. Can ayone help me please?

    # OK # Importing comments…
    WordPress database error: [syntax error near ” at line 1]
    SELECT signature, email, url, ipaddress FROM spm_members WHERE id =

    WordPress database error: [syntax error near ‘)’ at line 1]
    INSERT INTO wp_comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_content, comment_approved, user_id) VALUES (1, ”, ”, ”, ”, ‘2001-08-13 03:33:40’, ‘Hi…The song your refering to is absolutley beautiful…It\’s called \”Look On Down From The Bridge\” by Mazzy Star. The album is called \”Among My Swan\”. All Mazzy\’s albums are incredible and have the same feel to them. If you like the song you\’ll defintiley like the album. It\’s a singer named Hope….and her voice is beauty.
    I guess i should say something about the Sopranos…I love it….and I have a crush on Tony Soprano…his confidence….power
    Sonia’, ‘1’, )

    WordPress database error: [syntax error near ” at line 1]
    SELECT signature, email, url, ipaddress FROM spm_members WHERE id =

    WordPress database error: [syntax error near ‘)’ at line 1]
    INSERT INTO wp_comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_content, comment_approved, user_id) VALUES (1, ”, ”, ”, ”, ‘2001-08-13 03:34:18’, ‘Hi…The song your refering to is absolutley beautiful…It\’s called \”Look On Down From The Bridge\” by Mazzy Star. The album is called \”Among My Swan\” All Mazzy\’s albums are incredible and have the same feel to them. If you like the song you\’ll defintiley like the album. It\’s a singer named Hope….and her voice is beauty.
    I guess i should say something about the Sopranos…I love it….and I have a crush on Tony Soprano…his confidence….power
    Sonia’, ‘1’, )

    email me@ webmaster@thesopranos.com if you can help me.

  6. Pierre Igot says:

    Not an expert here, but I cannot help but notice that there is mix of apostrophes and backticks in your stuff. I know that backticks as item enclosers are supported to some extent, but I don’t exactly know to what extent — and I don’t know whether mixing them with apostrophes works or not. Just a thought.

  7. uno says:

    I have no idea. No clue what I can add to make it work. I’m not a programmer.

  8. Shad’s Pad » Blog Archive » says:

    […] Using the information found here, I had managed to get to the above state: where my archives were working fine, but the rest of it was acting wonky. Well, deleting the placeholder html file I created seem to fix it all. If anyone sees any problems, please let me know! […]

  9. Eshin Direct - Digital Nomad » Blog Archive » Move to WordPress says:

    […] How did I do the conversion? Betalogue provides an excellent how-to in his post “From pMachine to WordPress” post. […]

  10. MishMish says:

    can this be done w/ a pre-existing WP blog? I set up PixelFrame.Org/blog to “learn” WP to see if I wanted to move from pMachine. My personal blog is MishMish.Org. Now that I know I really like WP can this be used to move everything from mishmish.org to pixelframe.org/blog since it isn’t empty?

    I still have to move mishmish.org b/c it’s being hosted on another server so pMachine isn’t installed on the same DB as WP, but after I move it is that possible?

  11. Pierre Igot says:

    MishMish: The obvious problem that you are going to get is that you’ll have two sets of entries with the same ID numbers. Each blog entry has its own ID and it starts at 1, so if you have, say, 100 entries in WP blog #1 and 200 entries in WP blog #2, importing WP blog #1 into WP blog #2 would replace the first 100 entries of WP blog #2 by the 100 entries of WP blog #1. At least that’s what I suspect.

    So you are probably looking at getting a tool that can change the ID numbers of the existing entries so that they don’t conflict with the imported entries. (They would still be sorted properly by date and category and everything.) It might take some PHP skills. Your best bet is to ask the question in the WP forums.

    Good luck!

  12. MishMish says:

    thank you…that makes sense & to be honest the existing one was just to learn WP anyway, so I wouldn’t mind if they overwrite.

    my next problem is that I have multiple blogs on pMachine. can multiple blogs on pmachine be converted to WP? I know at present WP doesn’t support multiple blogs.

    Honestly, I would like one to remain on pMachine (b/c I really like it the way it is) & only convert the other to WP, is that possible? If not, I would convert both if that can be done.

  13. Pierre Igot says:

    WP doesn’t support multiple blogs, but there’s nothing that prevents you from importing each pMachine blog into WordPress, then saving the imported blog from WordPress as a MySQL dump, and then importing the dumb into another install of WordPress elsewhere on the same server. (You can have multiple copies of WordPress on the same server. Just make sure each WP blog uses its own prefix for the MySQL tables.)

  14. Fuzz Martin :: FuzzMartin.com » Blog Archive » Importing Posts from pMachine 2.4 to WordPress 2.0.1 says:

    […] Oh, before I go – I do have another idea to migrate to WordPress, but it involves first installing WordPress 1.5, then migrating your posts to pMachine using this script, then upgrading WordPress to 2.0 (or whatever the latest version is when you’re reading this.) […]

  15. Jaanus on the internet says:

    Migrating a blog from pMachine to WordPress 2

    I just helped someone to migrate from pMachine to WordPress 2. Now there’s this page available that walks and talks you through it and links to a script that supposedly does the conversion. The conversion seemed to go kinda fine,…

  16. Shad’s Pad » Blog Archive » New Blog Tool says:

    […] Using the information found here, I had managed to get to the above state: where my archives were working fine, but the rest of it was acting wonky. Well, deleting the placeholder html file I created seem to fix it all. If anyone sees any problems, please let me know! […]

  17. DailyTechTalk goes Wordpress | DailyTechTalk says:

    […] Well, it appears that someone has heard my cry and posted a script and another person posted a how-to for deploying the […]

  18. Bill Rowell » Migrating a pMachine Website to WordPress says:

    […] I went for answers. Pretty quickly I found two articles about migrating pMachine to WordPress 1.5 here with some actual PHP code to import the pMachine blog here. So, I was off to a good […]

  19. Pardon our dust - News and Views says:

    […] process since there is no pMachine-to-WordPress import script shipped with WordPress but I found one on the web and, after a bit of hacking and several cleanings of the WordPress database, I’ve managed to […]

Leave a Reply

Comments are closed.