That's not a valid data URI:
Data URLs - HTTP | MDN[
^]
You need to specify the correct MIME type for the image - eg:
image/jpeg
,
image/png
, etc. You have only specified "image", which is not a valid MIME type.
There also shouldn't be a space between the semi-colon and
base64,
.
Also,
fetchAll
returns an array containing all of the rows returned by the query. You want to fetch the value of the first column of the first row, which you've already done with
fetchColumn
.
Try:
$stmt->execute();
if($image = $stmt->fetchColumn()){
echo '<img src="data:image/jpeg;base64,'.base64_encode($image).'" style="margin-top: 100px;width: 100px; height: 100px; border-radius: 50px;">';
} else {
echo '<i class="fa fa-user-circle" style="font-size: 50px;"></i>';
}