Don't think that was the answer he was looking for =]. Here's how I
retrieve images stored as blobs.
$query = "select File, Type from Pictures_Data where id=$id";
$result = mysql_query($query);
$data = mysql_result($result, 0, "File");
$type = mysql_result($result, 0, "Type");
Header( "Content-type: image/$type");
echo "$data";
Btw, if you are going to be storing a large number of pictures or other
binary files as blobs, try to put them in their own table. I original
had one table with miscellanous information in it as well as the blobs,
and it did get slow on certain queries. Creating two tables with the
records linked via id solved the problem.
Regarding the post about storing blobs in databases. I agree that in
days past that it was not a good idea to do such because it does have a
serious impact on database performance. However, has anyone been paying
attention to the cost of hardware these days? Anyone with a serious
project should have plenty of money to throw hardware at the problem.
Perhaps not elegant, but I think performance and ease will beat elegant
any day of the week. My personal preference for storing images as blobs
is that it makes the syncing of my servers much easier. Rather than
using MySQL replication and rsync to keep the same content on my
servers, I can simply use MySQL replication and not have to worry about
my image data and the image being out of sync. Course perhaps a
dedicated machine to store the images served to multiple frontend
servers via NFS might work better, but again, performance has been
sufficient so far in my experience that I'm not worried about it. I
would be interested in other's thoughts on how to best tackle the
problem in a multiple server situation. HTH
--
Barry Jeung Team Lynx, Inc.
Senior System Engineer 1217 Montgomery Avenue
http://www.TeamLynx.com Second Floor
E-Mail: [EMAIL PROTECTED] San Bruno, CA 94066-1521
Phone: 650.589.3200 Fax: 650.589.2555
> -----Original Message-----
> From: Rick Emery [mailto:[EMAIL PROTECTED]]
> Sent: Friday, September 14, 2001 10:58 AM
> To: [EMAIL PROTECTED]
> Subject: RE: [PHP-DB] Another Image prob
>
>
> The consensus is that it is best if you DO NOT store the
> images as blobs in
> a database. Rather, store the images in separate files and
> store the names
> of those files in the database. Then retrieve the file names for the
> database, open the image files, and then send the images to
> the client's
> browser. Storing images as blobs tends to make the database unwieldy.
>
> -----Original Message-----
> From: Todd Moy [mailto:[EMAIL PROTECTED]]
> Sent: Friday, September 14, 2001 1:46 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Another Image prob
>
>
> I'm new at this and i'm sure that this has been answered before, but
> anyway...
> I am trying to retrieve images from a MySQL database. They
> are stored as
> BLOBs with the following table format:
>
> Database metonym_metonym - table imgs
> Field Type Attributes Null Default Extra
> fk_proj_id int(3) No 0
> imgname varchar(30)
> imgtype varchar(20)
> img blob
>
> Keyname Unique Field
> PRIMARY Yes fk_proj_id
>
> Is it possible to do this with a printf/ img src statement?
> Also, I have heard some talk about header information on
> retrieval-> how
> does this relate to retrieving an image?
>
> Bear in mind that these images are being uploaded via HTML form
> Thanks in advance
> METONYM
>
> --
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail:
> [EMAIL PROTECTED]
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail:
> [EMAIL PROTECTED]
>
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]