• I am writing a script to move comments from my Joomla blog into WP. I am using version 2.1 to the do the import (for various reasons), and I will upgrade once it’s done. The script will import the comments from the Akocomments plugin for Joomla into WordPress.

    Inside of a loop, I iterate over all the comments in Joomla, grab the relevant data and close the link to the Joomla DB. I then open a link to the WP db, find the post ID, and close that link. I then call,

    $comment_id = wp_new_comment( $commentdata );

    to insert the comment into the WP database. However, when I do this, I get the following errors:

    Warning: mysql_error(): 5 is not a valid MySQL-Link resource in /.../public_html/wordpress/wp-includes/wp-db.php on line 177
    Warning: mysql_affected_rows() [function.mysql-affected-rows]: A link to the server could not be established in /home/admin/domains/gorobotics.net/public_html/wordpress/wp-includes/wp-db.php on line 183

    Does anyone have any insight? I’m not skilled enough with PHP/MySQL to figure out the intricacies of the db connections.

    Do I need to specifically close each connection before connecting to another DB (I’m doing this)? Can I simply use different link variables for the different links? How does WP create a link to the DB via the “wp_new_comment()” function?

    I’m assuming that my scripts connecting and disconnecting from the WP database is somehow throwing off the functions ability to connect, but I don’t know how to get around it.

    Thanks.

  • The topic ‘script to import comments from Joomla to WP – mySQL connection errors’ is closed to new replies.