PHP problem

Philippines
April 23, 2012 6:34pm CST
Does anyone here help me in my coding in PHP any help will be appreciated. I want to create script that detects if there is an internet connection, if there is an internet connection then my script will connect to the online hosting mysql database. But if there is no connection then it will connect to the localhost database. Thanks for the replies.
1 response
• India
24 Apr 12
Hi, If I was not wrong fsockopen command can be used for the same purpose. if(fsockopen("www.mylot.com",80)) { ...connect to online hosting mysql database } Put the above code in loop and check after every 10 min or so.. as u wish or use http_response_code if response code is 200 then proceed else do not do anything. There is one more method of using exec in PHP. But most of the persons are not comfortable using the same.
• Philippines
24 Apr 12
Thanks for the info, greatly appreciated but when I run my site on a localhost machine, I am encountering errors in connection. Well, I hope I can solve it but I will study your algorithm. Thanks