3

I've an array that gives me an image blob in the 3rd dimension.

but I need the image, i tried with SQL

<?php $global = \Database::getInstance()->execute('SELECT CONVERT(VarChar(40), image)
    FROM mm_product2 
    WHERE id = '.$referenzen['id'])->fetchAllAssoc(); ?>
<?php print_r($global);?>

It show this error:

Fatal error: Uncaught exception Exception with message Query error:
You have an error in your SQL syntax; check the manual that corresponds
to your MySQL server version for the right syntax to use near 'VarChar(40),
image) FROM mm_product2 WHERE id = 23' at line 1 (SELECT CONVERT(VarChar(40), 
image) FROM mm_product2 WHERE id = 23

without the expressions it works but i get that blob value again like in the standard array:

[image] => 85392c33-a0f7-11e4-acb9-08606e695836 ) 

May I know how to convert that value in PHP or only in SQL ??

1 Answer 1

3

use mysql query to get the blob data in a variable and then use this

'<img src="data:image/jpeg;base64,' . base64_encode($image) . '" width="200" height="200">'
Sign up to request clarification or add additional context in comments.

6 Comments

my cms dont allow me to querry and i dont want to type in database information in this template. any other ideas ?
just replace $image of my code with your $global and remove convert statement
<?php $global = \Database::getInstance()->execute('SELECT image FROM mm_product2 WHERE id = '.$referenzen['id'])->fetchAllAssoc(); ?> echo '<img src="data:image/jpeg;base64,' . base64_encode($global) . '" width="200" height="200">';
looks good, i only get that error for now: base64_encode() expects parameter 1 to be string, array given. but ill work around tomorrow =) hopefully i can make a string from that. Thank you all !!!
@mike please mark it useful if this ans show u sme path
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.