cahamilton Posted April 21, 2009 Share Posted April 21, 2009 Hey guys. I'm midway through creating my mashup website and I've run into an error. I've basically written a line of code, that will detect whether or not there is any data contained within the feed sources and output an error message as required. But, I've run into a problem were it is detecting no content from feed sources, where feeds don't exist. I still get the error message I coded in, but a HTTP request failed error message on top of it. Here's an example of what I mean. http://cahamilton.at-uclan.com/fyp/query.php?artist=Amiina Here is a source were the feed exists, but there is no content. Hence the error message is output. http://cahamilton.at-uclan.com/fyp/query.php?artist=jackson+united Here is a source were the feed DOESNT exist. The same error message is output, but with the PHP warnings messages aswell. Would there be any way to work around this and avoid the PHP error messages? Link to comment https://forums.phpfreaks.com/topic/155049-solved-http-request-failed/ Share on other sites More sharing options...
rhodesa Posted April 21, 2009 Share Posted April 21, 2009 $xml = @simplexml_load_file($url); that will hide the initial simplexml error. then, in your code after, make sure you use IF statements to make sure there is a feed: if($xml && $xml->news){ foreach($xml->news as $news){ } } Link to comment https://forums.phpfreaks.com/topic/155049-solved-http-request-failed/#findComment-815509 Share on other sites More sharing options...
cahamilton Posted April 21, 2009 Author Share Posted April 21, 2009 You my friend, are brilliant! For days I've been trying to figure that out! Just out of interest, what impact does the @ sign have in front of the simplexml_load_file? All my simplexml statements have been without that, but thats seems to have fixed the problem pretty easily. Link to comment https://forums.phpfreaks.com/topic/155049-solved-http-request-failed/#findComment-815545 Share on other sites More sharing options...
rhodesa Posted April 21, 2009 Share Posted April 21, 2009 all it does is suppress any php errors. it will work on any php function Link to comment https://forums.phpfreaks.com/topic/155049-solved-http-request-failed/#findComment-815584 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.