// Now based upon import-mt.php // Configurable parameters for existing phpslash database: $dbuser = ""; // PHPslash username $dbpassword = ""; // PHPslash password $dbhost = ""; // PHPslash hostname $dbdb = ""; // PHPslash database // end of configuration parameters. // // History: // // 2005/01/06 - Initial release just to get wordpress working my blog :-). if (!file_exists('../wp-config.php')) { die("There doesn't seem to be a wp-config.php file." . "You must install Wordpress before you import any entries."); } require('../wp-config.php'); $step = $HTTP_GET_VARS['step']; if (!step) $step = 0; ?> WordPress › Import from PHP Slash

WordPress

Howdy! We’re about to begin the process to import all of your PHP Slash entries into WordPress. Before we get started, you need to edit this file (import-phpslash.php) and change a couple of lines so we know where to find your phpslash database.

If you've done that and you’re all ready, let's go! Remember that the import process may take a minute or so if you have a large number of entries and comments. Think of all the rebuilding time you'll be saving once it's done. :)

We will now try to import your PHPslash stories in to WordPress. Watch the following output to see how it goes.

Error establishing a database connection! This probably means that the connection information in your import-phpslash.php file is incorrect. Double check it and try again.

WordPress Support Forums

"); } if (!@mysql_select_db($dbdb,$phpslash_dbh)) { die("

We're having a little trouble selecting the PHPslash database.

WordPress Support Forums

"); } // Rip out the entries from PHPslash, matching up user names. $psl_story_query = mysql_query("SELECT psl_author.author_name, " . "psl_story.title, psl_story.dept, " . "psl_story.intro_text, " . "psl_story.body_text, " . "psl_story.date_available " . "FROM psl_story LEFT JOIN psl_author ON " . "psl_author.author_id=psl_story.user_id " . // for debugging use id=240 // "WHERE psl_story.story_id=\"240\"" . "ORDER BY psl_story.story_id ASC;"); if (!$psl_story_query) { die("Invalid query: " . mysql_error()); } while ($psl_story_entry = mysql_fetch_array($psl_story_query, MYSQL_ASSOC)) { $wordpress_entry['post_author'] = $psl_story_entry['author_name']; $wordpress_entry['post_title'] = $psl_story_entry['title']; $wordpress_entry['post_category'] = 1; // FIXME $wordpress_entry['post_content'] = "[ from the " . $psl_story_entry['dept'] . " dept. ]

" . $psl_story_entry['intro_text'] . "

" . $psl_story_entry['body_text']; $wordpress_entry['post_date'] = date("Y-m-d H:i:s", $psl_story_entry['date_available']); $wordpress_entry['post_date_gmt'] = $wordpress_entry['post_date']; $wordpress_entry['post_modified'] = date("Y-m-d H:i:s"); $wordpress_entry['post_modified_gmt'] = gmdate("Y-m-d H:i:s"); // Let's check to see if it's in already if ($wpdb->get_var("SELECT ID FROM $tableposts WHERE post_title = " . "\"{$wordpress_entry['post_title']}\" " . "AND post_date = " . "\"{$wordpress_entry['post_date']}\"")) { echo "[IGNORED] " . $wordpress_entry['post_title'] . "
"; } else { // Find the corresponding author if ($user_id = $wpdb->get_var("SELECT ID FROM " . "$tableusers WHERE user_login = " . "\"{$wordpress_entry['post_author']}\"")) { $wordpress_entry['post_author'] = $user_id; echo "[imported] " . "[ " . $psl_story_entry['author_name'] . "] " . $wordpress_entry['post_title'] . "
"; } else { $wordpress_entry['post_author'] = 0; // general user echo "[imported] " . "[general]" . $wordpress_entry['post_title'] . "
"; } $wpdb->query("INSERT INTO $tableposts ( post_author, post_title, post_category, post_content, post_date, post_date_gmt, post_modified, post_modified_gmt) VALUES (\"{$wordpress_entry['post_author']}\", \"{$wordpress_entry['post_title']}\", \"{$wordpress_entry['post_category']}\", \"{$wordpress_entry['post_content']}\", \"{$wordpress_entry['post_date']}\", \"{$wordpress_entry['post_date_gmt']}\", \"{$wordpress_entry['post_modified']}\", \"{$wordpress_entry['post_modified_gmt']}\")"); $post_id = $wpdb->get_var("SELECT ID FROM $tableposts WHERE " . "post_title = \"{$wordpress_entry['post_title']}\" " . "AND post_date = \"{$wordpress_entry['post_date']}\""); // FIXME: We just insert category 1 for the moment. $wpdb->query("INSERT INTO $tablepost2cat ( post_id, category_id) VALUES ($post_id, \"{$wordpress_entry['post_category']}\")"); } ?>

That's all for now. If the above didn't show any error messages then the imported data should now show up in your WordPress.

This is the PHPslash import script by Jon Masters.