On Fri, 20 Sep 2002 12:51:20 -0700 Howard Fuchs <[EMAIL PROTECTED]> wrote:

> I am using the following PERL (dbi/dbd-mysql) code snippet to display a
> blob image to browser. Problem is that it is displaying as low
> resolution  I guess I am missing something. BTW it displays perfectly
> well using graphical interface MySQLFront.  Any tips or hints would be
> appreciated.
> 
> begin snip------------------------------------>
> ($dbh->{LongReadLen} = 50000);
> ($sth = $dbh->prepare( "SELECT * FROM testblob where number =
> '$number'")) or die $DBI::errstr;
> $rv=($sth->execute )or die $DBI::errstr;
> while (($number,$picture,$fieldblob) = $sth->fetchrow){
> print "Content-type: image/jpeg \n\n";
> print "$fieldblob";
> <-------------------------------------------end snip 

I'm slightly surprised the image is displaying at all.  It is binary and
you don't appear to have switched STDOUT to binmode.  After you do, you
will have to expand the "\n"s to "\xd\xa" yourself.  The '"'s in the last
print are not needed.

On the DBI side, you may be able to save a lot of database effort by using
placeholders.  You are also not getting any error checking from fetchrow()
unless you '$dbh -> {RaiseError} = 1'.

I hope you have '-w' in the '#!' line and are using 'use strict;'.

-- 
Mac :})
** I normally forward private questions to the appropriate mail list. **
Ask Smarter: http://www.tuxedo.org/~esr/faqs/smart-questions.html
Give a hobbit a fish and he eats fish for a day.
Give a hobbit a ring and he eats fish for an age.

Reply via email to