debashish
Member
Posted 2 years ago #
I am working on utility that imports posts from Joomla to WordPress. The code is kept in a sub-folder inside the WP root. The PHP has the following code, but I get the following error when I run it:
Code:
require_once('../wp-config.php');
require('../wp-blog-header.php');
require_once ('../wp-includes/functions.php');
$my_post = array();
$my_post['post_title'] = 'title';
$my_post['post_content'] = 'content';
$my_post['post_status'] = 'publish';
$my_post['post_author'] = $ID;
$my_post['post_date'] = '<date>';
$my_post['post_category'] = array($wpsection);
$my_post['post_name'] = $post_name;
$my_post['post_excerpt'] = 'excerpt text';
// Insert the post into the database
$post_id = wp_insert_post( $my_post );
Error:
Warning: mysql_error(): 9 is not a valid MySQL-Link resource in C:\xampplite\htdocs\wp27nirantar\wp-includes\wp-db.php on line 685
Warning: mysql_error(): 9 is not a valid MySQL-Link resource in C:\xampplite\htdocs\wp27nirantar\wp-includes\wp-db.php on line 685
Warning: mysql_affected_rows(): 9 is not a valid MySQL-Link resource in C:\xampplite\htdocs\wp27nirantar\wp-includes\wp-db.php on line 691
Warning: mysql_insert_id(): 9 is not a valid MySQL-Link resource in C:\xampplite\htdocs\wp27nirantar\wp-includes\wp-db.php on line 694
debashish
Member
Posted 2 years ago #
turn on debugging. or echo back the mysql query.
mr_prateekjain
Member
Posted 2 years ago #
Facing the same kind of problem..
Has anyone found the solution????
turn on debugging. or echo back the mysql query.
mr_prateekjain
Member
Posted 2 years ago #
I tried that... I am trying to open another separate database. It works fine and i get the required result from that database also. But after accessing that database executing any query to wordpress database generates that error !!!
thats right, thats because youre not closing the other connection. MySQL needs to be told when it is making a new connection.
use the new_link parameter.
http://us.php.net/function.mysql-connect
and ffr, thats not the same kind of problem.
mr_prateekjain
Member
Posted 2 years ago #
dude i have checked many times.. i am closing that another connection properly. If i dont use that other database it works perfectly fine. But after using that database it generates that error.
mr_prateekjain
Member
Posted 2 years ago #
$dbhost1 = 'localhost';
$dbuser1 = 'xxxx';
$dbpass1 = 'xxxx';
$conn1 = mysql_connect($dbhost1, $dbuser1, $dbpass1) or die('Error connecting to mysql');
$dbname1 = 'xxxx';
mysql_select_db($dbname1);
$query = "SELECT email FROM users where id= '".$login."'";
$result = mysql_query($query);
$emailidArray = mysql_fetch_array($result);
$email = $emailidArray[0];
mysql_close($conn1);
mr_prateekjain
Member
Posted 2 years ago #
hey thanks man..
new_link parameter worked perfectly fine..
Thanks :)
im not a man. surprise surprise -- girls know shit too.
mr_prateekjain
Member
Posted 2 years ago #
i dont mind who u are.. i got my problem solved.
thanks.