我目前正在使用HostGator,但我的问题是无法使用HostGator文件连接到我的在线数据库(也就是HostGator)。我希望,如果我有互联网连接,我将连接到我的在线数据库,但如果没有,我将连接到我的离线localhost数据库。这是我的密码:
$checknet = @fsockopen("www.mysite.com", 80);
if(isset($checknet)) {
mysql_connect('mysite.com OR ip of mysite','username','password');