vForums Support :: Programming & Coding :: Programming Discussion :: file_get_contents Errors - View Topic
 |  |
| dog199200 Guest | file_get_contents Errors (5th Feb 10 at 2:39pm UTC) | | Does anyone know what could be causing these errors?
 Code: - Warning: file_get_contents() [function.file-get-contents]: Couldn't resolve host name in *directory path* on line 177
-
- Warning: file_get_contents(http://server1.shiningashes.net/status.txt) [function.file-get-contents]: failed to open stream: operation failed in *directory path* on line 177
The error is coming from the file_get_contents() function when trying to call the file http://server1.shiningashes.net/status.txt its acting if the file doesn't exist when it does exist, you can click that link and see for yourselves.
Here is the fill code:
 Code: - <?php
- $server_status = file_get_contents("http://server1.shiningashes.net/status.txt");
- $update_file = "http://server1.shiningashes.net/status.txt";
-
- $Headers = @get_headers($update_file);
- if (preg_match("|200|", $Headers[0])) {
-
- echo $server_status;
-
- } else {
- echo "<FONT COLOR=#DD0000><B>\"OFFLINE\"</B></FONT>";
- }
- ?>
The code is a server status check, its one of three files that are involved in the check, so if you think it is incomplete then that would be why. You can see where the server status is suppose to work, here http://www.divineshadowsonline.com (under Alpha Sever in the Server Status side bar on the left). And you can see what its trying to call here: http://server1.shiningashes.net/status.txt <-- what you see in the file is everything in it, its just a document containing the outcome of the last part of the system.
I'm some what wondering if me seeing that error is a DNS problem, but i fan ipconfig /flushdns ans i still get the error, plus darkmage has commented on seeing it as well. Only think i can think of is if the error ain't with my coding, then its with my server. I have the permissions set correctly so everyone can view that file. The reason i'm not to sure if its a code problem is because it does work every now and again
| |
| Michael Moderator
    
![[Avatar]](http://av.wservices.co.uk/av.png) Recoding the future Posts: 4,043 Status: Offline Gender: Male Location: UK Joined:
Additional Groups: Coding Team
  
pmvForum | Re: file_get_contents Errors (5th Feb 10 at 3:23pm UTC) | | Your coding seems ... over the top tbh.
You can just do the file_get_contents, and if it doesn't return, then report it's offline... There's no reason why that shouldn't work. Try the relative URL, instead of the direct URL | |
| dog199200 Guest | Re: file_get_contents Errors (5th Feb 10 at 9:18pm UTC) | | the complication with that is i'm kind of have a sub-domain assigned to that sub-domain, which is assigned to no-ip which always keeps my dymanic ip and turns it into static so if it wont work with a sub-domain it wont work at all
edit: I also have no idea how to do a status check with the file_get_contents, so i did it that way, checking to see if the file exists first, is you want to optimize the code go ahead XD | |
| |
 |  |
|