I have the flowing sql query the MainImage datatype is image (think binary)
SELECT dbo.tbl.strPartNumber AS SKU, dbo.tbl.strDesc AS ProductName, dbo.tbl.strExtendedDesc AS ShortDesc,
(SELECT TOP 1 dbo.tblImg.imgData FROM dbo.tblImg WHERE dbo.tblImg.strpartnumber = dbo.tbl.strpartnumber AND bitDefaultImage = '1') as MainImage,
dbo.tbl.bitInactive AS Inactive FROM dbo.tbl WHERE bitWebstoreItem = '1'
now I can get all data to show but not the image this what I have for the img show
what I would like to do is select image from outside datasource and add it to new or existing product in woocommerce
$DefaultImage = base64_encode($row["MainImage"]);
if (isset($DefaultImage) && $DefaultImage !== null) {
echo '<td align="center" style="border-color:#000000"><img src="data:image/jpeg;base64,' . $DefaultImage . '" width="150" height="150"></td>';
} else {
echo "<td align=\"center\" style=\"border-color:#000000\">No image available.</td>";
}
it only shows a broken image
I have search the forum and no solution is found yet
I have done a var_dump and get string(0)
I read the following https://stackoverflow.com/questions/10958350/display-image-in-php-page-from-sql-database but this is for only the images.
also this https://stackoverflow.com/questions/55785364/update-image-in-php-and-mysql-database
EDIT
SCREENSHOT OF DATA enter image description here
data:image/jpegis a bit of an assumption then? Try testing it with an image you've prepared and you know is definitely a JPEG. Also I know you can see the data in the database - but if you look again, that wasn't what I asked you.