Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/238.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP获取存储在数据库中的图像_Php_Mysql_Image - Fatal编程技术网

PHP获取存储在数据库中的图像

PHP获取存储在数据库中的图像,php,mysql,image,Php,Mysql,Image,我在名为image的longblob字段中手动插入了一个图像…图像是.gif,所以我输入了mimetype作为'image/gif',但它不工作 $result=mysql_query("SELECT image FROM page WHERE number=$ide"); while($image=mysql_fetch_array($result)) { header('Content-type:'.$image['mimetype']); echo $ima

我在名为image的longblob字段中手动插入了一个图像…图像是.gif,所以我输入了mimetype作为'image/gif',但它不工作

  $result=mysql_query("SELECT image FROM page WHERE number=$ide");

 while($image=mysql_fetch_array($result))
 {
     header('Content-type:'.$image['mimetype']);


    echo $image['image'];

请帮助它显示一些随机的二进制文本,而不是图像。它还显示未定义的索引mimetype我在定义它时有没有做错什么?

您需要在SQL查询中获取mime类型,如下所示:

$result=mysql_query("SELECT image, mimetype FROM page WHERE number=$ide");

mime类型应该是
image/gif

您需要在SQL查询中获得mime类型,如下所示:

$result=mysql_query("SELECT image, mimetype FROM page WHERE number=$ide");

mimetype应该是
image/gif

这样做了..错误通知没有出现,但图像也没有显示。页面是空的?@treffynnons听起来像图像数据在插入数据库时可能已损坏。如果您在数据上与原始图像文件的数据有什么不同吗?有没有。错误通知没有出现,但图像也没有显示。页面为空?@treffynnons听起来像图像数据在您将其插入数据库时可能已损坏。如果您对数据和原始图像文件的数据进行编辑,是否有任何不同?编辑-我将mimetype更改为image/gif,但图像仍不会出现编辑-我将mimetype更改为image/gif,但图像仍不会出现