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.

In reply to syntax error near "){" by greymoose

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.