sprinkles Posted June 2, 2007 Share Posted June 2, 2007 I'm building a script with the last.fm datafeeds. When a incorrect username is given to the script, the last fm site throws a 404, and results in this PHP error: Warning: simplexml_load_file(http://ws.audioscrobbler.com/1.0/user/RichardJohn/tasteometer.xml?with=) [function.simplexml-load-file]: failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found in /home/richardm/public_html/lastfmcompatibility.php on line 12 Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "http://ws.audioscrobbler.com/1.0/user/RichardJohn/tasteometer.xml?with=" in /home/richardm/public_html/lastfmcompatibility.php on line 12 There was a problem loading the data feed. Is there a way to catch this error and just present a friendly error? Quote Link to comment https://forums.phpfreaks.com/topic/54008-solved-simplexml-catching-404/ Share on other sites More sharing options...
Lumio Posted June 2, 2007 Share Posted June 2, 2007 <?php $xml = @simplexml_load_file(....); if (!$xml) die('An error occured...'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/54008-solved-simplexml-catching-404/#findComment-267015 Share on other sites More sharing options...
sprinkles Posted June 2, 2007 Author Share Posted June 2, 2007 Thanks a lot! Quote Link to comment https://forums.phpfreaks.com/topic/54008-solved-simplexml-catching-404/#findComment-267019 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.