我有两个文件(b.php和showimages.php) b.php使用这个:
<?php include('showimages.php'); ?>
但它不起作用,但当我尝试打开showimages.php本身时,它会显示内容。 这个问题是什么?
b.php:
<!DOCTYPE html>
<html>
<body>
<div class="product-row">
<?php include('showimages.php'); ?>
</div>
</body>
</html>
showimages.php:
<?php
$db = mysqli_connect('localhost', 'root', '', 'online_shopping');
$query = "SELECT * FROM products " ;
$result = mysqli_query($db, $query);
$row = mysqli_fetch_assoc($result) ;
header("Content-type: image/jpg");
echo $row['pric1'];
?>
答案 0 :(得分:3)
您的HTML已经发送了标题Content-Type: text/html
,因此您无法为图片发送另一个标题。您需要通过HTML获取图片,而不是include
:
<img src="showimages.php" alt="some image">