MySQL retrieving GIF/JPEG from blob

From: Date: Tue, 08 Aug 2000 15:40:34 +0000
Subject: MySQL retrieving GIF/JPEG from blob
Groups: php.db 
Request: Send a blank email to php-db+get-1857@lists.php.net to get a copy of this message
Hello all! Well I've been at this for a while now, so I thought I'd throw this out to the list. I'm working on a project for a client, and as part of the requirements for their system, they'd like to be able to store small images within MySQL v3.22.23. I've gotten the code to insert the image into the database working just fine, with the help of addslashes() and stripslashes(). Here's where things get a bit bizarre. For testing I'm using the MySQL logo(surprise), and it's length before going into the database is a nice small 2642 bytes. Unfortunately, when it comes back -out- of the database it's size is then 2634 bytes. The question is: What happened to those 12 bytes? Unfortunately, strlen() has no idea what to make of the raw image binary's size until I use stripslashes() at which point its size has already decreased to 2634 bytes. However, just for kicks is did a strlen(stripslashes(addslashes($image))) and it returns 2642 bytes, as it should. This to me points the finger to mysql. Any ideas would be greatly appreciated, otherwise I'll have to give up this super-cool feature and just store the image in the filesystem somewhere. Feel free to bug me for actual code as well, the only reason I'm not including it immediately is that I started this email on my Mac and I don't trust it with attachments much. ;) Regards, Adam W. Dace

« previous php.db (#1857) next »