2013-04-02 52 views
0

基本上這是一個搜索欄和我走的搜索項,並把它的API調用的網址,但我越來越未能加載外部實體「」

警告:使用simplexml_load_file()函數.simplexml-load-file]:I/O警告:未能加載外部實體「」

有什麼想法?

代碼:

if (!empty($_POST['searchbird'])){ 
    $searchbird=rawurlencode($_POST['searchbird']); 
    $searchCode = "http://ebird.org/ws1.1/data/obs/region_spp/recent?rtype=subnational2&r=US-AZ-013&sci=$searchbird"; 
    $url_headers = @get_headers($searchCode); 

    if($url_headers[0] == 'HTTP/1.1 200 OK') { 
     $xml = simplexml_load_file($url); 

     print_r($xml); 

    } else { 
     // Error 
     echo $searchCode; 
     print_r($url_headers); 
     exit("failed to load XML"); 
    } 


} else { 
    $searchbird = ''; 
    $form = "<form method='post'> 
     <strong>Enter the name of a Bird</strong> 
     <input type='text' name='searchbird' value='$searchbird' /> 
     <input type='submit' name='submit' value='submit' /> 
    </form>"; 
    echo $form; 
} 
+0

你在哪裏定義'$ url'? –

+0

您的網址爲空或爲空;你在哪裏設置它? – Ibu

+0

在你的配置中,你看着allow_url_fopen –

回答

0

你想在函數變量從$url改變$searchCode$url變量是空的,沒有設置任何地方。

if (!empty($_POST['searchbird'])){ 
    $searchbird=rawurlencode($_POST['searchbird']); 
    $searchCode = "http://ebird.org/ws1.1/data/obs/region_spp/recent?rtype=subnational2&r=US-AZ-013&sci=$searchbird"; 
    $url_headers = @get_headers($searchCode); 

    if($url_headers[0] == 'HTTP/1.1 200 OK') { 
     $xml = simplexml_load_file($searchCode); 

     print_r($xml); 
.... 
+0

非常感謝你......它總是簡單的答案! –

相關問題