连接到数据库以进行免费托管时出错

问题描述 投票:0回答:2

我有免费托管的问题,前段时间我想连接到在线数据库,但我收到错误消息:

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'>"));

如果得到帮助,我将非常感激。谢谢。

php mysql database web-hosting
2个回答
0
投票

您必须使用localhost而不是“mysqlX.000webhost.com”

$ I_DB ["host"] = "mysqlX.000webhost.com"; 

0
投票

可能存在某些原因,例如数据库服务提供程序的脱机状态或无法从远程位置设置的localhost。因此,请尝试与提供商联系。

© www.soinside.com 2019 - 2024. All rights reserved.