2015-01-08 51 views
0

我有一個php頁面,它檢索遠程圖像的完整url,然後它必須顯示它。但即時通訊錯誤「無法顯示,因爲它包含錯誤」。我需要這個腳本的應用程序。有人可以在這裏指出錯誤嗎?PHP圖像標題錯誤,獲取無法顯示,因爲它包含錯誤?

該網址工作完美,因爲當我回顯網址..它正確迴應它。所以即時通訊假設錯誤是在圖像標題或什麼的。請幫忙。

請注意,數據庫存儲JPEG的文件名...爲​​ex..filename.jpg

<?php 
    if (isset($_GET['id'])){ 
     $id = $_GET['id']; 
    } 

    $username="--"; 
    $password="--"; 
    $hostname = "xxxx"; 

    //connection string with database 
    $dbhandle = mysql_connect($hostname, $username, $password) 
    or die("Unable to connect to MySQL"); 


    // connect with database 
    $selected = mysql_select_db("1775125_tourist",$dbhandle) 
    or die("Could not select examples"); 

    $query = mysql_query("Select * FROM photo_details WHERE place_id = '$id'"); 
    while($row = mysql_fetch_assoc($query)){  
     $imageData = $row["photo"]; 
    } 

    $url = "http://optimusone.net46.net/testing_only/uploads/".$imageData; 
    header('Content-Type: image/jpg'); 
    imagejpeg($url); 

?> 

回答

0

試試這個:這個代碼把你的代碼的頂部..

/ Report all PHP errors (see changelog) 
error_reporting(E_ALL); 

// Report all PHP errors 
error_reporting(-1); 

// Same as error_reporting(E_ALL); 
ini_set('error_reporting', E_ALL); 

More Info

0

你的問題在於你輸出使用PHP的圖像的方式。

如果您在服務器上的圖像文件,並希望它傳輸到瀏覽器,請嘗試使用示例代碼從這個PHP文件頁面:

http://php.net/manual/en/function.imagecreatefromjpeg.php(#示例1)

如果您有URL位於其它Web服務器上的圖像,並希望以顯示它使用HTML嘗試這一行:

print "<img src='$url' alt=''>"; 
相關問題