I am trying to get the image which is stored in the blob format in Mysql Database.I am using the following code.
index.php
<img src='image.php?questionid=questionid&question=question1&answer=answer1&author=myname' />
image.php
<?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'] ;
?>
In index.php I didn't get any image.So When I enter the URL for image.php I am getting the following error in forefox.
The image “URL” cannot be displayed because it contains errors.
I am using php5.3 and mysql 5.1.36 .
What I did wrong.I went through almost all forums and no clues.Please help me on this.