php图像检索不';不显示mysqli

php图像检索不';不显示mysqli,php,mysqli,Php,Mysqli,从phpmyadmin数据库渲染存储的图像时出现问题 我有两个文件,第一个是image.php,它应该从数据库中检索图像: <?php ini_set('display_errors',1); error_reporting(E_ALL); $conn = mysqli_connect("hostname","username","password"); if(!$conn) { echo mysql_error(); } $db = mysqli_select_db("imagestor

从phpmyadmin数据库渲染存储的图像时出现问题

我有两个文件,第一个是image.php,它应该从数据库中检索图像:

<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
$conn = mysqli_connect("hostname","username","password");
if(!$conn)
{
echo mysql_error();
}
$db = mysqli_select_db("imagestore");
if(!$db)
{
echo mysql_error();
}
$ano = $_GET['ano'];
$q = "SELECT aphoto,aphototype FROM animaldata where ano='$ano'";
$r = mysqli_query("$q",$conn);
if($r)
{

$row = mysqli_fetch_array($r);
$type = "Content-type: ".$row['aphototype'];
header($type);

readfile($ano);
echo mysql_real_escape_string.$row['aphoto'];
}
else
{
echo mysql_error();
}

?>

和show.php,假设它显示检索到的图像:

 <?php
//show information
ini_set('display_errors',1);
error_reporting(E_ALL);

include "connect.php";


$q = "SELECT * FROM animaldata";
$r = mysqli_query($conn,$q);
if($r)
{
while($row=mysqli_fetch_array($r))
{
//header("Content-type: text/html");
echo "</br>";
echo $row['aname'];
echo "</br>";
echo $row['adetails'];
echo "</br>";

//$type = "Content-type: ".$row['aphototype'];
//header($type);
echo "<img src=image.php?ano=".$row['ano']." width=300 height=100/>";


}
}
else
{
echo mysql_error();
}
?>

当我尝试show.php时,我得到以下结果:

我将非常感谢任何帮助,因为我尝试了许多不同的代码,但我找不到解决方案,仍然得到相同的结果


谢谢。

您应该去掉
readfile
行,因为它不是必需的,还可以去掉下面一行中的
mysqli\u real\u escape\u字符串。否则这看起来是可行的,但如果不知道你是如何存储这些图像的,我就不能确定了。例如,如果将它们存储为base64编码,则需要回显base64解码字符串。

在第一个文件中,它应该是
$r=mysqli\u query($conn,$q)
而不是
$r=mysqli\u查询($q',$conn)
在某些地方,您正在使用mysql功能,在某些地方,mysqli请修复相同的功能。mysqli_real_escape_string是一个函数,您需要更改这部分内容或引用,将图像作为原始编码数据存储在SQL db中效率非常低,从数据库和图像检索和输出的角度来看,它要快得多,而且更干净,将图像存储在文件系统中,然后将文件路径保存到数据库中。谢谢,但是如果我想发布我的网站并将用户图像存储在我的服务器中,我可以保留这种类型的存储图像吗?。您对此有参考吗…非常感谢