How to get data from other database ?
Since other database have a different information (host,username,password) with the default one define at wp-config.php so using $wpdb command always failed.
I create native php-mysql database connect in one file (grabdata.php) and include it in widget (php-enable-widget using plugin) and this code screw other $wpdb command after this code.
grabdata.php :
<?
$con = mysql_connect('localhost','username','pass')
or die(mysql_error());
mysql_select_db('mydatabase') or die(mysql_error());
$sql = 'SELECT <code>inbox</code>.<code>ReceivingDateTime</code>, <code>inbox</code>.<code>SenderNumber</code>, <code>inbox</code>.<code>TextDecoded</code>'
. ' FROM inbox'
. ' WHERE (<code>inbox</code>.<code>RecipientID</code> =\'0811111111111\')'
. ' ORDER BY <code>inbox</code>.<code>ReceivingDateTime</code> DESC'
. ' LIMIT 0 , 10';
$result = mysql_query($sql) or die(mysql_error());
echo "<ul>";
while ($line = mysql_fetch_array($result)){
echo "<li><small>From : </small><strong>".$line[1]."</strong> <small>@ ".$line[0]."</small><span style=\"color:#CCC\">".$line[2]."</span></li>";
};
echo "</ul>";
mysql_close($con);
?>
Note : this grabdata.php give the true result and run smooth if run independently.
The error message in almost every place that acces wp database after that code is :
Warning: mysql_error(): 10 is not a valid MySQL-Link resource in ...my-path../wp-includes/wp-db.php on line 615
wp-db on line 615 is :
// If there is an error then take note of it..
if ( $this->last_error = mysql_error($this->dbh) ) {
$this->print_error();
return false;
}
Any help will be appreciated..
Thanks..
Cakra
[moderated--bump removed. Please refrain from bumping as per Forum Rules]