vForums Support Banner



 

Welcome Guest! Please Login or Register
vForums Support :: Programming & Coding :: Programming Discussion :: file_get_contents Errors - View Topic
Topic Rating: *****
Printable View
dog199200
Guest
file_get_contents Errors (5th Feb 10 at 2:39pm UTC)
Does anyone know what could be causing these errors?

Code:
 
  1. Warning: file_get_contents() [function.file-get-contents]: Couldn't resolve host name in *directory path* on line 177
  2.  
  3. 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:
 
  1. <?php
  2. $server_status = file_get_contents("http://server1.shiningashes.net/status.txt");
  3. $update_file = "http://server1.shiningashes.net/status.txt";
  4.  
  5. $Headers = @get_headers($update_file);
  6. if (preg_match("|200|", $Headers[0])) {
  7.  
  8. echo $server_status;
  9.  
  10. } else {
  11. echo "<FONT COLOR=#DD0000><B>\"OFFLINE\"</B></FONT>";
  12. }
  13. ?>
 


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 {Unsure}
Michael
Moderator
*****

[Avatar]
Recoding the future

Posts: 4,043
Status: Offline
Gender: Male
Location: UK
Joined:  

Additional Groups:
Coding Team
***


Reputation: 58%  


pmtwittervForum
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 {Smile}
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 {Unsure} 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
 Printable View

All times are GMT+0 :: The current time is 4:13am
Page generated in 0.4206 seconds
This Forum is Powered By vForums (v2.4)
Create a Forum for Free | Find Forums