edzillion Posted March 6, 2008 Share Posted March 6, 2008 I am making a wordpress widget and I want it to deal with a site being down. The code: $xml = simplexml_load_file('scripts/pricefeed.php'); if($xml) { //display widget etc. Pricefeed checks if the URL exists and returns false if it does not: <?php $fileUrl = "http://dgcsc.org/goldprices2.xml"; $AgetHeaders = @get_headers($fileUrl); if (preg_match("|200|", $AgetHeaders[0])) { // file exists readfile($fileUrl); } else { // file doesn't exist return false; } ?> it works fine if the URL is there but if it isnt I get the error 'parser error : Document is empty' on the simple_xml_load line. Do I need a try catch statement or something? Not v. experienced at that.... Quote Link to comment Share on other sites More sharing options...
edzillion Posted March 7, 2008 Author Share Posted March 7, 2008 anyone? Quote Link to comment Share on other sites More sharing options...
edzillion Posted March 7, 2008 Author Share Posted March 7, 2008 at all? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.