Sten 0 Report post Posted February 4, 2008 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
turbopowerdmaxsteel 0 Report post Posted February 4, 2008 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
yordan 10 Report post Posted February 4, 2008 @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
Sten 0 Report post Posted February 5, 2008 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
TavoxPeru 0 Report post Posted February 8, 2008 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
Sten 0 Report post Posted February 8, 2008 Thanks, that works now!I added else{echo " 0";}to it so that it shows 0 if it can't find it! Share this post Link to post Share on other sites