Hello fellow Monks!
I'm currently writing a small CGI-Script that, among other things, tries to feed images from a Mysql-DB to the browser.
But for some strange reason i can't read both content-type and data from within the same SQL-Statement:
$type should be 'image/gif', 'image/png' or 'image/jpeg', depending on the output of Image::Info.my $sql = "select type,data from bilder where id =?"; my $sth = $dbh->prepare($sql); $sth->execute( $q->param('id') ); my $error = 0; (my $type, my $data) = $sth->fetchrow() || ( $error = 1 ); binmode(STDOUT); if ( $error == 1 ) { print $q->header( -type => "image/gif" ); open( IN, "templates/keinbild.gif" ); binmode(IN); while (<IN>) { print; } close(IN); } else { print $q->header( -type => $type ); print $data; }
Adding a warn($type) gives:
DB is as follows:[Sun Dec 18 11:24:34 2005] [error] [client 192.168.x.y] (\xa2\x80, ref +erer: http://server.lan/cgi-bin/index.pl?action=picman
Does anyone know what's wrong here?CREATE TABLE `bilder` ( `id` int(11) NOT NULL auto_increment, `data` longblob NOT NULL, `type` enum('image/jpeg','image/gif','image/png') NOT NULL default ' +image/jpeg', `resx` int(11) NOT NULL default '0', `resy` int(11) NOT NULL default '0', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;
Thank you in advance
Braindead_One
In reply to Mysql and Images by Braindead_One
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |