简体   繁体   English

如何使用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);

Error: 错误:

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/

I get this error when i want to fetch something or try to connect 当我想取东西或尝试连接时出现此错误

您必须从托管cpanel的选项Remove MySQL中添加IP地址,以允许远程访问。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM