簡體   English   中英

即使圖像已保存到數據庫也無法顯示(回顯)圖像

[英]unable to display(echo) image even image has been saved to database

/*此代碼在本地主機上工作(回顯圖像)但不顯示在實時站點上 */ 請幫助,,,,

 <?php echo "<img src=geti/tipb_geti.php?id=$lastid  width=200px height=180px >";

/*php塊下面是tipb_geti.php文件*/

 <?php
      include("connect.php");
      $id=@addslashes($_REQUEST['id']);

      $image_query=@mysql_query("select image from tipuranibasti where id=$id");
        $image_row=@mysql_fetch_assoc($image_query);


            $image=$image_row['image']; 
            header("content-type: image/jpeg");

          echo $image;              

?>    

您的實時服務器上的 memory 限制是多少? 您正在此處制作圖像數據的兩份副本:

$image=$image_row['image']; 

這是毫無意義的。 你可以簡單地擁有

echo $image_row['image'];

相反,為自己節省額外的浪費/無意義的復制操作。

檢查你的字符編碼。 livedb 可能有 UTF8 編碼或服務器有,但你沒有,如果沒有,output 是什么? 注釋掉header("content-type: image/jpeg"); 並檢查您是否在現場和本地獲得相同的東西。

哦,我更願意:

<?php print'<img src="geti/tipb_geti.php?id=' . $lastid . '"  width="200px" height="180px" />';

使您的 html/xhtml 格式更合理並print'test'; print"test"; 由於“$var”將 output 是 $var 的內容,而“$var”不會,因此過熱程度有所降低。 但是不要以為你從中獲得超高速:P 你不會注意到更多的性能,我只是認為它提供了更好的代碼。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM