$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'password1';
$dbname = 'DB01';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql for First Database');
mysql_select_db($dbname, $conn) ;

This first connection is where the php file is stored.

$dbhost02 = '192.168.0.16';
$dbuser02 = 'root';
$dbpass02 = 'password2';
$dbname02 = 'DB02';


$db02 = mysql_connect($dbhost02, $dbuser02, $dbpass02) or die ('Error connecting to mysql for Second Database');
mysql_select_db($dbname02, $db02) ;

This Second Connection is where i'm trying to connect on my secondary database

Check /etc/mysql/my.cnf in the second server for bind-address option and change it from 127.0.0.1 to 192.168.0.16 after that reload or restart MySQL.

Then make sure the firewall of that server is not blocking 3306 port (which is the default port form MySQL).

bye.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.