hey all,
The server where I host my website went into unscheduled maintenance, a few minutes later I noticed that the IP of the server changed (they probably moved my website to another server since it's paid hosting although shared). So, my website was back online but some things weren't working.
Some HTML files were just empty, but then I noticed it happened only to html files I use for caching. Those html files get updated once in a while with a php script I made myself. Those scripts go like this:
$fi=file_get_contents("http://mywebsite.com/getnews.php");
$FileHandle = fopen("/home/path/to/www/news.html", 'w') or die("can't open file");
fwrite($FileHandle, $fi);
fclose($FileHandle);
That code worked before, but not after the change. The new server has php 5 just like the one I had before, though, for some reason after running the script, the html file does not get written. If I manually edit the html file and then run the script, the html file goes blank, meaning that an empty string is written to the file.
After a bit of research and testing, I see that the problem is the file_get_contents();
function because if I replace that with any string, the html file gets written like it should with the string given, so basically the problem is that file_get_contents
is not retrieving the data from the specified file/URL.
Upon further testing, I realize that it's just my website which is not working with that function, because I tried the microsoft website and it works, I get all the html code from their website, which just gave me an idea of what was going on....
I think maybe my server's DNS is not up to date, so when requesting my website URL it gets the old IP address, which leads to nowhere. I'm almost certain of this because I manually had to ipconfig /flushdns
on my computer to get the new IP address once they moved my website.
That has to be the problem here. Anyway, when can I expect my server to update their cached DNS table? 24 hours?
Also, just in case you were wondering;
$fi = file_get_contents("/home/path/to/website/getnews.php");
will work BUT that way, i'll get the PHP code and not the php output, so I need to retrieve the URL and not the relative path. But, I bet there's another way to do this, so any help is greatly appreciated.