Extensão MySQL Melhorada

add a note add a note

User Contributed Notes 1 note

up
-12
veit dot heise at heise-media dot eu
1 month 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
}

with:
$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.

WHY???
To Top