我收到一条错误消息,指出我的图像由于错误而无法显示。我查看了该问题的先前解决方案,但没有一个取得任何成功。我确保没有空行,我有单独的 html 和 php,并且我在标题之前有正确的信息。任何帮助都会很棒,因为我认为我错过了一些小东西。代码如下。
html:
<?php
$images = "SELECT product_images.img_name, product_images.img_tag, product_images.img_family, product_images.img_id FROM product_images
INNER JOIN product_list
ON product_images.img_tag = product_list.product_tag && product_images.img_family = product_list.name_family";
$img_list = mysql_query($images);
while($rows = mysql_fetch_array($img_list)) {
$img_name = $rows['img_name'];
$img_tag = $rows['img_tag'];
$img_family = $rows['img_family'];
$img_id = $rows['img_id'];
//echo $img_name;
?>
<div>
<img src="view.php?imgid=<?php echo $img_id; ?>" />
</div>
<?php
}
?>
php:
<?php
require_once('april25_connect.php');
$dir = "product_images/";
$img = $_GET['imgid'];
$query = "SELECT * FROM product_images WHERE img_id = '$img'";
//echo $query,'<br>';
$newid = mysql_query($query);
if (!$newid) {
echo "Query '$newid' failed <br />\n";
echo "Error: ".mysql_error()." <br />\n";
exit;
}else{
while($returned_id = mysql_fetch_array($newid)) {
$name = $returned_id['img_name'];
$tag = $returned_id['img_tag'];
$family = $returned_id['img_family'];
header ("Content-type: image/jpeg; image/gif; image/png");
$fullpath = $dir.$name;
echo $fullpath;
}
}
?>