Hostgator 远程访问本地 php 文件中的数据库
Hostgator remotely access database in local php file
我目前正在使用 HostGator,但我的问题是我无法使用我的 localhost
PHP 文件连接到我的在线数据库(即 HostGator)。我希望如果我有互联网连接,我将连接到我的在线数据库,但如果 none 我将连接到我的离线 localhost
数据库。这是我的代码:
$checknet = @fsockopen("www.mysite.com", 80);
if(isset($checknet)) {
mysql_connect('mysite.com OR ip of mysite','username','password');
mysql_select_db('db');
} else {
mysql_connect('localhost','root','');
mysql_select_db('db');
}
另外,我已经将我的IP地址添加到数据库的访问白名单中了。但是,从远程系统访问数据库仍然不起作用。
您必须将您的 public IP 地址列入白名单。
a) Google "what is my ip"
b) Follow the tutorial on this link.
我目前正在使用 HostGator,但我的问题是我无法使用我的 localhost
PHP 文件连接到我的在线数据库(即 HostGator)。我希望如果我有互联网连接,我将连接到我的在线数据库,但如果 none 我将连接到我的离线 localhost
数据库。这是我的代码:
$checknet = @fsockopen("www.mysite.com", 80);
if(isset($checknet)) {
mysql_connect('mysite.com OR ip of mysite','username','password');
mysql_select_db('db');
} else {
mysql_connect('localhost','root','');
mysql_select_db('db');
}
另外,我已经将我的IP地址添加到数据库的访问白名单中了。但是,从远程系统访问数据库仍然不起作用。
您必须将您的 public IP 地址列入白名单。
a) Google "what is my ip"
b) Follow the tutorial on this link.