Jump to content
xisto Community
Sten

Can Anyone Help Me Detecting 503 Errors In Php Progs ?

Recommended Posts

Sorry for being a pain and not knowing much PHP, I'm not that brilliant at it.Anyway, can anyone help me with this little code?<?php$online = file_get_contents("http://www.habbo.com/habbo_count_xml.action;'>http://www.habbo.com/habbo_count_xml.action;) or die(" 0");$onlinee = trim(strip_tags($online));echo $online;?>All it does is show how many people are online on Habbo Australia. It works, except when Habbo is down (it is now because the servers carked it) it gives me this.Warning: file_get_contents(http://www.habbo.com/habbo_count_xml.action) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 503 Service Unavailable in /home/habfront/public_html/templates/habbo_front_1/index.php on line 132It still shows the 0 for when it dies except how do I get it not to show the error?There's also another problem with it, well I'm using Joomla and when Habbo is down, along with the error, it also stops the component and modules and that from showing which is really annoying.So how do I make it so it doesn't show the error and just shows the 0 and the whole site will work properly?Once again, I'm a PHP nub!

Share this post


Link to post
Share on other sites

Use the error_reporting() function to set the error_reporting directive as follows:-

 

Disable: error_reporting(0);

Enable: error_reporting(1);

 

Use this before the block you want to disable error reporting. You should however turn it back on, otherwise all errors will go undetected.

 

 

<?phperror_reporting(0);  // Disable Error Reporting$online = file_get_contents("http://www.habbo.com/habbo_count_xml.action; or die(" 0");error_reporting(1); // Turn it back on$onlinee = trim(strip_tags($online));echo $online;?>

Share this post


Link to post
Share on other sites

@turbopowerdmaxsteel : great idea, disabling and re-enabling error reporting !@Sten : I touched your topic title in order to make it more specific, feel free to correct it if I misunderstood it.Yordan

Share this post


Link to post
Share on other sites

That works, it doesn't show the error!Except... it's still stopping the modules and component and the Joomla header and everything else after it from loading.Which basically means that when Habbo is down, my site is down which is quite annoying. I know other fansites use the same code and it doesn't do it for them, but they aren't using a CMS, the most they use is Cutenews for their news.Anyone know how to make it load other things? PHP (well the Joomla things) and anything (content and images etc) after the code doesn't show.

Share this post


Link to post
Share on other sites

That works, it doesn't show the error!

 

Except... it's still stopping the modules and component and the Joomla header and everything else after it from loading.

 

Which basically means that when Habbo is down, my site is down which is quite annoying. I know other fansites use the same code and it doesn't do it for them, but they aren't using a CMS, the most they use is Cutenews for their news.

 

Anyone know how to make it load other things? PHP (well the Joomla things) and anything (content and images etc) after the code doesn't show.

I guess that it stops because you use the die() function, the file_get_contents() function returns a string with the contents of the file on success and FALSE on failure, so, instead try the following:

<?phperror_reporting(0);  // Disable Error Reporting$online = file_get_contents("http://www.habbo.com/habbo_count_xml.action;; // Turn it back onif ($online) {  $onlinee = trim(strip_tags($online));  echo $onlinee;}?>
Best regards,

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.