将BLOB图像转换为二进制值

I uploaded an image in a database in phpadmin into the column image of type blob.Therefore i want to select the binary code of the image so i do this

SELECT CONVERT( `image` 
USING binary ) AS image
FROM `license` 
WHERE `l_name` = 'lamen'
LIMIT 0 , 30

the results are similar to what i am looking for, but i dont think i get the pure binary as it returns this.

�PNG \Z \0\0\0IHDR\0\0\0h\0\0\0f\b\0\0\0�tC�\0\0\0sRGB\0���\0\0\0gAMA\0\0�� UT+M�TQ�K�+�k(��\0\0\0\0IEND�B`�

Just a bunch of mess. i deleted alot of the lines cause its just this similar code.

HOWEVER. if i say SELECT CONVERT(imageUSING binary) as image fromlicensewherel_name='lamen'

it returns image and under it [BLOB-413 bytes]

and if i click it i get

SELECT * FROMlicenseWHERE CONVERT(imageUSING utf8 ) = CAST( 0x89504e470d0a1a0a0000000d4948445200000068000000660802000000a8744386000000017352474200aece1ce90000000467414d410000b18f0bfc6105000000097048597300000ec300000ec301c76fa8640000013249444154785eedd7310ec2401443c15c823b736ce8e956cf2b218d441b1796e7273cefe7e577d0c073f08c47be0d28ee109ce21477f7585b9cc559dc5fbcb551451555540f15284e7177cf87c5599cc5fd34e03bee9085e21477f79e589cc5599cefb843058a53dcddf36171166771fe725577c007f0e13d519ce2ee1e628bb3388bab5e7cd31c545145754aac0a471555542b4dd31c545145754aac0a471555542b4dd31c545145754aac0a471555542b4dd31c545145754aac0a471555542b4dd31c545145754aac0a471555542b4dd31c545145754aac0a471555542b4dd31c545145754aac0a471555542b4dd31c545145754aac0a471555542b4dd31c545145754aac0a471555542b4dd31c545145754aac0a471555542b4dd31c545145754aac0a471555542b4dd31c5451bd4bf5032b956b28b9120d8b0000000049454e44ae426082 AS BINARY ) ;

Which i suspect is what i want...i however...cant get my select statement to return that code even if i say select CONVERT(image USING utf8 )

Thansk for the help

PS.I know its easier to upload the image to a file and just save the path. and already know how to do this. I however am trying something and want to use this way. Thanks again.

Assuming you have the image as a string, you don't need to actually convert it at all, or worry about the charset. It looks like you're over complicating it.

Use one of the BLOB types as your field type (BLOB / MEDIUMBLOB etc) and make sure you escape the string when you insert into the database. These field types are not charset dependent but are "BINARY" types.

If you're using the old mysql_() functions, use mysql_real_escape_string() to escape the value, but if you're using PDO or mysqli_() then user prepared statements as this does the escaping for you (nice and easy).

When you select, no need to do anything then either - it should just work.