cidaris has asked for the wisdom of the Perl Monks concerning the following question:

I've been working on getting images into a MySQL database, and I think I'm doing things correctly, but wanted verification. I've seen the same thing done several different ways, so thought someone might have input.

I've been using the documentation, the DBD/DBI documentation, and a number of PM threads.

my $img = $query->upload('pc_img'); $img = <$img>; my $id = $query->param('pc_id'); my $sql = "INSERT INTO data_table (id, image) VALUES (?, ?); + ## id is BIGINT type, image is LONGBLOB type my $sth = $dbh->prepare($sql) or die "Couldn't prepare: $DBI::errstr\n +"; $sth->execute($id, $img) or die "Unable to execute query: $DBI::er +rstr\n"; $sth->finish; $dbh->disconnect;

I'm using MySQL AB's MySQLCC to view the contents of the database, and it shows there is indeed data in the 'image' field, and if I upload a GIF, it's GIF89a and then garbled text, and if it's a JPG, usually y0ya-garbage-garbage so I think binary data is being put into these BLOB type fields.

However, the problem is as follows: MySQLCC doesn't display GIFs, only supporting 'free' formats ( damn Unisys ) and when I try to open a JPG from the viewer, it says "An error occurred while opening this image."

So my dilemna is 'Am I doing it right?' and suffering from a limitation of the program? Am I doing it wrong? Is there another application out there that will allow me to connect to a database and show me information w/o me having to install something server-side like MySQLMan?

I'd really appreciate your input.