MySQL Forums
Forum List  »  Perl

Re: Need Help : DBI works with Perl but doesn't works with CGI
Posted by: Bill Karwin
Date: May 03, 2006 04:29PM

One thing I notice is that you're not outputting an HTTP header. When I try the script as you have it, I get this in my apache/logs/error.log:

[Wed May 03 15:27:35 2006] [warn] /cgi-bin/test.pl did not send an HTTP header


You might also want to use the object-oriented methods in CGI.pm, for example:


print header(), start_html('CGI-DBI');

my $dbh = DBI->connect('dbi:mysql:test','root','subazini');
if (!defined($dbh)) {
print h2('Can\'t connect');
die "Can't connect \n";
}

print h2('connected'), br();

$dbh->disconnect();

print h3('disconnected'), end_html();

Regards,
Bill K.

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.