I have a piece of code that looks up two arrays from a table in a MySQL database and is then supposed to print out the information on a web page. (Sorry to those monks of greater learning but I haven't got beyond using PERL for cgi.) The data is looked up by
exist_deadline.cgi which is called by
about_deadline.cgi
The
while loop (lines 30 -33 of
about_deadline.cgi) where the information is supposed to print out always results in error messages:
syntax error at /usr/lib/cgi-bin/about_deadline.cgi line 30, near ") {
+"
syntax error at /usr/lib/cgi-bin/about_deadline.cgi line 33, near "}"
I've found another thread asking the same question and triple checked the answers that monk received. The error disappears if I take the call to the second script out. I can't find a missing semicolon or extra brace (yes, my editor does colour code my syntax). That's not to say that it isn't there somewhere but I am bamboozled. I'm posting the code below. Can anyone see what I've missed?
about_deadline.cgi
my ($conf) = new Config::General(
-ConfigFile => 'somefile.conf',
-ExtendedAccess => 1
);
my ($databaseUser)=$conf->value("user");
my ($databaseName) = $conf->value("name");
my ($databasePw) = $conf->value("pass");
# Declare local variables
my ($dbh);
my ($stmt, $sth);
my (@deadlinetyp, @deadline);
my $i = 0;
<!--#exec cgi="/cgi-bin/exist_deadline.cgi" -->
while ($deadlinetyp[$i]) {
print $deadlinetyp[$i]." <b>".$deadline[$i]."</b><br>";
$i++;
}
exist_deadline.cgi
print header;
my ($conf) = new Config::General(
-ConfigFile => 'somefile.conf',
-ExtendedAccess => 1
);
my ($databaseUser)=$conf->value("user");
my ($databaseName) = $conf->value("name");
my ($databasePw) = $conf->value("pass");
# Declare local variables
my $dbh;
my ($stmt, $sth);
my @aRow;
my $j=0;
$dbh = DBI->connect($databaseName, $databaseUser,
$databasePw) || die "Connect failed: $DBI::errstr\n";
#Get available deadline details
$stmt = "SELECT dead_typ, dead_line FROM deadlines";
#Prepare and execute the SQL query
$sth = $dbh->prepare($stmt) || die "prepare: $stmt: $DBI::errstr";
$sth->execute() || die "execute: $stmt: $DBI::errstr";
while (@aRow = $sth->fetchrow()){
$deadlinetyp[$j] = @aRow[0];
$deadline[$j] = @aRow[1];
$j++;
}
# Clean up the record set and the database connection
$sth->finish();
$dbh->disconnect();
Thanks in advance for your help.