无法将blob存储的图像转换为图像格式(MySql和php)?

无法将blob存储的图像转换为图像格式(MySql和php)?,php,mysql,blob,Php,Mysql,Blob,我正在尝试获取Mysql数据库中以blob格式存储的图像。我正在使用以下代码。 index.php <img src='image.php?questionid=questionid&question=question1&answer=answer1&author=myname' /> <?php require_once('dbconfiguration.php'); $sql="SELECT image FROM tablename WHERE q

我正在尝试获取Mysql数据库中以blob格式存储的图像。我正在使用以下代码。
index.php

<img src='image.php?questionid=questionid&question=question1&answer=answer1&author=myname' />
<?php
require_once('dbconfiguration.php');
$sql="SELECT image FROM tablename WHERE questionid='{$_GET['questionid']}' and question='{$_GET['question']}' and answer='{$_GET['answer']}' and author='{$_GET['author']}'";
$STH = $DBH->query($sql);  
$STH->setFetchMode(PDO::FETCH_ASSOC);  
$row = $STH->fetch();  
ob_clean();
header("content-type: image/jpg") ; 
echo $row['image'] ; 
?>
我正在使用php5.3和mysql 5.1.36

我做错了什么。我浏览了几乎所有的论坛,没有任何线索。请帮我解决这个问题。

应该是:

<?php
require_once('dbconfiguration.php');
$sql="SELECT image FROM tablename WHERE questionid='{$_GET['questionid']}' and question='{$_GET['question']}' and answer='{$_GET['answer']}' and author='{$_GET['author']}'";
$STH = $DBH->query($sql);  
$STH->setFetchMode(PDO::FETCH_ASSOC);  
$row = $STH->fetch();  
ob_clean();
header("content-type: image/jpg") ; 
echo $row['image'] ; 
?>


因为您的数据库字段名为image而不是Efaq\u image

这是旧的。当我更改表字段名时,我也在php中更改了它。此处未更新。请立即查看更新的问题。您创建的查询也正确吗?你确定你的blob数据是有效的jpg图像吗?是的。我只存储了jpg,当我删除标题时,我可以在屏幕上看到二进制数据。谢谢Frederick Behrends。现在我解决了这个问题。这是因为我在尝试插入图像时添加了斜线。但是我在尝试获取图像时没有删除斜线。现在它已修复。谢谢你的帮助。
<?php
require_once('dbconfiguration.php');
$sql="SELECT image FROM tablename WHERE questionid='{$_GET['questionid']}' and question='{$_GET['question']}' and answer='{$_GET['answer']}' and author='{$_GET['author']}'";
$STH = $DBH->query($sql);  
$STH->setFetchMode(PDO::FETCH_ASSOC);  
$row = $STH->fetch();  
ob_clean();
header("content-type: image/jpg") ; 
echo $row['image'] ; 
?>