in reply to Printing DBI errors from a CGI script

You have RaiseHell set to 1, which means that DBI methods will die on you and print error messages on the screen (where available).
Well, guess what? Your browser will surely complain if your script sends an error message instead of the expected HTTP header.

You either need to print the HTTP header first
print header; #... do other stuff
or do this
use CGI::Carp qw(fatalsToBrowser);

--perlplexer

Replies are listed 'Best First'.
Re: Re: Printing DBI errors from a CGI script
by lestrrat (Deacon) on Apr 18, 2002 at 21:03 UTC

    ... or simply surround the DBI calls with eval()..

    my $dbh; eval { ## bunch of dbi calls.. $dbh = DBI->connect( ... ); $dbh->do( blah ); $dbh->commit; $dbh->disconnect; }; if( my $err = $@ ) { eval{ $dbh->rollback }; eval{ $dbh->disconnect }; ## print header, html, and $err exit 1; # or return, whatever }