Hello all. This script I have did work on linux/apache and my service provider has told me the cgi-handler has been properly set up. I am able to get hello world test to display to a web page. My problem comes in when I try to connect to a mysql DB on IIS 6. My script reads as follows:
Logically to me the script should function. What I get in return from the web page is:
CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers.
Code:
use DBI qw(:sql_types);
$title = 'EnergyWise Device Test - Reading List';
$start = 40;
print <<ENDSTART;
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en-US">
<head>
<title>$title</title>
</head>
<body>
<h1 style="font-size:1.2em">$title</h1>
ENDSTART
$dbName = "DBI:mysql:database";
$dbUser = "myuserid";
$dbPass = "mypass";
$numrows = 5;
$dbh = DBI->connect($dbName, $dbUser, $dbPass) || die "Die: $DBI::errstr\n";
$sql = "select max(raw_id) from data";
$sth = $dbh->prepare($sql) || die "prepare: $sql: $DBI::errstr";
$result = $sth->execute() || print "execute: $sql: $DBI::errstr";
@record = $sth->fetchrow();
$maxid = @record[0];
$sth->finish();
print $maxid," rows found. Last ", $numrows, " shown below:";
$minid = $maxid-$numrows;
$sql = "select * from data where raw_id > \"$minid\"";
$sth = $dbh->prepare($sql) || die "prepare: $sql: $DBI::errstr";
$result = $sth->execute() || print "execute: $sql: $DBI::errstr";
while (@results = $sth->fetchrow() ) {
print "<p>Row ";
print @results[0];
print ":<p>";
print show(@results[1]);
}
$sth->finish();
$dbh->disconnect();
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime(time);
$now = sprintf "%4d-%02d-%02dT%02d:%02dZ", 1900+$year,$mon+1,$mday,$hour,$min;
print p('Processed '.$now."\n");
print end_html;
sub show {
$_[0] = escapeHTML($_[0]);
$_[0] =~ s/\r\n/<br>/g;
$_[0] =~ s/\n/<br>/g;
return $_[0]; }
CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers.
Comment