Here, i'm trying to fetch the image from database. In my database i can see a image file size ([BLOB - 62.3 KiB]). But, it didn't work. i didn't get any error here. i'm confused where i made a mistake here?

<?php
    include('config.php');

    ini_set('display_errors', '1');
    error_reporting(E_ALL);

    try
    {
        $stmt = $conn->prepare('SELECT * FROM ebusers');
        $conn->errorInfo();
        $stmt->execute();
        while($row = $stmt->fetch(PDO::FETCH_ASSOC)) 
        {   
            echo '<img class=shadow_img width=160 height=180 src="data:image/png;base64,' . base64_encode($row['UserProfilePicture']) . '"/>';
            echo $row['Address'];
            echo "<br>";echo "<br>";echo "<br>";echo "<br>";
        }
    }
    catch(PDOException $e)
    {
        'Error : '.$e->getMesssage();
    }
?>

tried.. not working

Quote from here:
Remember that you can't retreive BLOB data using something like this :

<?php
$sql = 'SELECT * FROM sometable LIMIT 1';
$stmt = $dbh->prepare($sql);
$stmt->execute();
$stmt->setAttribute(PDO::FETCH_ASSOC);
$row = $stmt->fetch();

$myFile = $row['file'];
?>

Instead of this you should try following approach:

<?php
$sql = "SELECT mime, file FROM sometable LIMIT 1"; 
$stmt = $dbh->prepare($sql); 
$stmt->execute(); 

$stmt->bindColumn(1, $mime,); 
$stmt->bindColumn(2, $file, PDO::PARAM_LOB); 

$stmt->fetch(); 

header('Content-type: '.$mime);
print $file; 
?>
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.