alin19 Posted August 12, 2008 Share Posted August 12, 2008 i have a script that worked perfectly a few days ago, and today i get the error: Warning: file_get_contents(http://www.bnro.ro/nbrfxrates.xml) [function.file-get-contents]: failed to open stream: No route to host in /opt/lampp/htdocs/curs_val.php on line 7 Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /opt/lampp/htdocs/curs_val.php:10 Stack trace: #0 /opt/lampp/htdocs/curs_val.php(10): SimpleXMLElement->__construct('') #1 {main} thrown in /opt/lampp/htdocs/curs_val.php on line 10 <html> <?php $url = 'http://www.bnro.ro/nbrfxrates.xml'; $curs = file_get_contents($url); $xml = new SimpleXMLElement($curs); foreach( $xml->Body->Cube->Rate as $rate ){ $final = array(); foreach( $rate->attributes() as $att => $value ){ if( $att=='currency' ) $final['currency'] = (string) $value; if( $att=='multiplier' ) $final['multiplier'] = (string) $value; } $final['rate'] = (string) $rate; if( empty($final['multiplier']) ) $final['multiplier'] = 1; echo $final['currency'].' '.$final['multiplier'].' '.$final['rate'].'</br>'; } ?> </html> Quote Link to comment Share on other sites More sharing options...
Xurion Posted August 12, 2008 Share Posted August 12, 2008 Manual says about the file_get_contents function: A URL can be used as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename and List of Supported Protocols/Wrappers for a list of supported URL protocols. http://uk2.php.net/file_get_contents Quote Link to comment Share on other sites More sharing options...
alin19 Posted August 12, 2008 Author Share Posted August 12, 2008 i'm trying to solve the problem, it's conected with my dns server Quote Link to comment Share on other sites More sharing options...
Xurion Posted August 12, 2008 Share Posted August 12, 2008 It is still not working after you did what the manual says to do? 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.