MySQL Improved Extension

add a note add a note

User Contributed Notes 1 note

veit dot heise at heise-media dot eu
2 years ago
How to do?
I try to "shift" JPEG-files and RAW-files into a LONG_BLOB-field in my database. When I use following:

$db = ... connect to MYSQL-database;
$dir = opendir($specialdirectory);
$filename = readdir($dir);
$handle = fopen($specialdirectory.$filename);
$picture = stream_get_contents($handle);
$sql = "INSERT INTO table SET xyz=.... , picture=`".$picture."`";
if (!$res = $db->query($sql)) { error handling ....
// the field "picture" bounced against $picture

$dump = bin2hex($picture);
$sql = "INSERT INTO table SET xyz=...., picture=`".$picture."`";
// no error occurs.... but the content of the LONG_BLOB-field picture
// is not usable as a JPEG or RAW picture.... it is destroyed.

To Top