【问题标题】:how to connect two database on the different host at the same time using php and mysql?如何使用php和mysql同时连接不同主机上的两个数据库?
【发布时间】:2015-01-13 15:21:42
【问题描述】:
$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/

当我想获取某些东西或尝试连接时出现此错误

【问题讨论】:

  • 很确定这个错误总结了你遇到的整个问题:Access denied for user '******'@'********'
  • 并停止使用已弃用的mysql_* 函数。请改用 MySQLi / PDO。
  • 你能单独连接其中一个吗!,这似乎更像是一个访问问题

标签: php html mysql arrays database-connection


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-14
    • 2012-08-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多