I know this question has been asked many times but I couldnot solve this using any of them. I am new to sqlite and cannot understand what I am doing wrong.
WHAT I AM TRYING
I am trying to make a profile view page. I am able to fetch all details from my sqlite database but i am not able to display my profile picture.
TABLE STRUCTURE
**username|landline|mobile|email|profilepicture**
john |xxxxxxxx|xxxxxx|x@x.x|blob
WHAT I TRIED
$sql = "SELECT * FROM profile";
$query = $db->query($sql);
while($row = $query->fetchArray(SQLITE3_ASSOC) ){
echo "NAME = ". $row['user_name'] . "<br/>";
echo "LANDLINE = ". $row['user_landline'] ."<br/>";
echo "MOBILE = ". $row['user_mobile'] ."<br/>";
echo "EMAIL = ".$row['user_email'] ."<br/>";
header('Content-Type: image/png');
echo $row['user_profile_picture'];
}
<html>
<img src='profile.php?imgid=<?php echo $row['user_profile_picture'];?>'/>
</html>
But the image dosenot show and also the rest of the data dosenot display when i putheader('Content-Type: image/png');
Create an image.php:
<?php
$sql = "SELECT user_profile_picture FROM profile WHERE id = " . $_GET['id'];
$query = $db->query($sql);
$row = $query->fetchArray(SQLITE3_ASSOC);
header('Content-Type: image/png');
echo $row['user_profile_picture'];
In profile.php:
<img src='image.php?id=<?php echo $row['id'];?>'/>
来源:https://stackoverflow.com/questions/16954772/fetch-blob-image-from-table-and-display-it-using-php-sqlite3