我寫婁代碼從數據庫如何在php中顯示數據庫中的圖像?
<?php
mysql_connect("localhost","root","");
mysql_select_db("test");
$qry = "select id from image";
$res = mysql_query($qry) or die(mysql_error());
while($row = mysql_fetch_array($res))
{
echo "<img src=image.php?id='$row[0]'>";
}
?>
Image.php
<?php
$query = mysql_query("SELECT img FROM images WHERE id = ".$_GET['id']);
$row = mysql_fetch_array($query);
if($type=="pjpeg")
$type="jpeg";
header("Content-type:$type");
echo $row['img'];
?>
顯示圖像,但是這是不行的。它顯示空白圖像圖標。
如果您分析HTTP流量內容類型所做的頭說,你的形象? – Tobias
我不知道如何知道? – Jaydipsinh
你有一個Chrome瀏覽器或Firefox與螢火蟲插件?然後很容易在「網絡」選項卡中檢查它。查看轉到image.php?id =的請求,然後您應該看到服務器返回的內容。另外,還要確保你不前或 – Tobias