i have store an image into my database.

but i am unable to display the image what i have done till now is under.... any help will be appreciated. thanks in advance!

<?    
         $query="SELECT * from testimonial";
            $ret = mysqli_query($mysql,$query);
            if (isset($ret) && $ret->num_rows>0)
                { 

                    while($row=mysqli_fetch_array($ret))
                        {
                            $body=$row['body'];
                            $name=$row['name'];
                            $image=$row['img'];
                            ?>
                            <li>
                                <div class="frame-icon"><? echo "<img src=test_img.php?id=".$row['id']." width=150 height=150/>";?></div>
                                <p class="quote"><?php echo $body; ?><span><?php echo $name; ?></span></p>
                            </li>
                        <?php }
        echo "</table>";
    }
?>

and my test_img is

<?php require_once("header.php"); ?>
<?php require_once("admin/db.php"); ?>
<?php if (isset($_GET['id'])){

    $id=mysql_real_escape_string($_GET['id']);
    $query=mysql_query("SELECT *FROM testimonial WHERE id='$id' ");
    while($row = mysql_fetch_assoc($query))
    {
        $image=$row["img"];
    }
     header("content-type: image/png");
}
else{
    echo "error";
}
?>

i also try this one

<? echo '<img src="data:image/png;base64,' . base64_encode($row['img']) . '">';?>

I think this post might help you: http://stackoverflow.com/questions/4110907/how-to-decode-a-base64-string-gif-into-image-in-php-html

According to that post and a bit of experience in such matters, you either have a PHP page that outputs ONLY the image, and then put that page inside an <img> element's "src" attribute (e.g. <img src="image.php?id=1">), or you use something like <img src="data:image/gif;base64,<?php echo $base64_encoded_image; ?>">.

@minitauros thanks! but its not work for me as i have use both case and i have clearly show it in my thread.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.