如何使用PHP和MySQL同时连接不同主机上的两个数据库


how to connect two database on the different host at the same time using php and mysql?

$connection1 = mysql_connect($servername,$username,$password);
$db1 = mysql_select_db($dbname,$connection1);
some html and php code here
$connection2 = mysql_connect($servername1,$username1,$password1);    
$db2 = mysql_select_db($dbname1,$connection2);

错误:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user '*****'@'***.com' (using password: YES) in /home/
Warning: mysql_select_db() expects parameter 2 to be resource, boolean given in /home/
Warning: mysql_query() [function.mysql-query]: Access denied for user '******'@'********' (using password: NO) in /home/
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/

当我想获取某些内容或尝试连接时,我收到此错误

您必须在选项"删除MySQL"中添加托管cpanel中的IP地址以允许远程访问。