Php 连接到数据库以免费托管时出错
我对免费托管有问题,前一段时间我想连接到在线数据库,但收到错误消息:Php 连接到数据库以免费托管时出错,php,mysql,database,web-hosting,Php,Mysql,Database,Web Hosting,我对免费托管有问题,前一段时间我想连接到在线数据库,但收到错误消息: Warning: mysql_connect(): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. $ I
Warning: mysql_connect(): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
$ I_DB ["host"] = "mysqlX.000webhost.com";
$ I_DB ["user"] = "axx1xxx2_1xxme";
$ I_DB ["pass"] = "x857x49";
$ I_DB ["name"] = "a9x32_xdex";
$ Dbhost = $ i_DB ["host"];
$ Dbuser = $ i_DB ["user"];
$ Dbpass = $ i_DB ["pass"];
$ Dbname = $ i_DB ["name"];
mysql_connect ($ dbhost, $ dbuser, $ dbpass) or die (mysql_error ("Sorry error occurred on the connection to the database, while longer <meta Repeat http-equiv='refresh' content='0'>"));
mysql_select_db ($ dbname) or die (mysql_error ("Sorry error occurred on the connection to the database, while longer <meta Repeat http-equiv='refresh' content='0'>"));
如果能得到帮助,我非常感激。
谢谢。您必须使用localhost而不是mysqlX.000webhost.com
$ I_DB ["host"] = "mysqlX.000webhost.com";
可能有某些原因,如数据库服务提供商的脱机状态或无法从远程位置设置的本地主机。因此,请尝试与提供商联系。服务器是否允许远程连接?您可能无法连接到远程数据库。如果数据库是本地的,请更改[主机]=。。。to[host]=LocalHost这不是取决于您尝试连接的MySQL服务器是否位于本地主机上吗?