in reply to Missing right curly or square bracket at jsdisp.cgi line 178, at end of line syntax error at jsdisp.cgi line 178, at EOF

Hi, You may find it easier to locate errors in your code if it were restructured to clarify and simplify the logic and eliminate many brackets. Here is an example, it may not do exactly what you want but I hope this gives you the idea.
#!/usr/bin/perl use DBI ; use CGI qw(:standard); use CGI::Carp qw(warningsToBrowser fatalsToBrowser); my($username)= "someuser"; my($password)= "knownuser"; my($dbh)= DBI->connect ("DBI:mysql:hf", $username , $password); my($empName)= param("empName"); my($year) = param("year"); my($mon) = param("mon"); DBI -> trace(4 , 'dbitrace'); # logic my $result; if ($year && $mon){ $result = getResult($empName); } else{ $result = "Select year and month. <br>"; } # result print <<end_of_html; Content-type: text/html <html><head><title> Job Status Display Page</title></head> <body> $result <a href="/jsdisp.html" > Back </a> </body></html> end_of_html #process sub getResult { my $empName = shift; my $table = q!<table border="1" height="8%"> <tr valign="center" align="middle"> <td width="10%">Current Date</td> <td width="10%">Name</td> <td width="15%">Job Allocated</td> <td width="10%">Allocation Date</td> <td width="10%">Target Date</td> <td width="15%">Job Under Execution</td> <td width="15%">Job Pending </td> <td width="15%">Remark </td> </tr>!; my $date1 = $year.$mon.'00'; my $date2 = $year.($mon++).'00'; my $sql = "select * from jobStat where cdate > ? and cdate < ?"; my $noMsg = "No records found for given date.<br>"; if ($empName){ $sql .= " and empName='$empName'"; $noMsg = "No records found for $empName for given date.<br>"; } my $sth = $dbh->prepare($sql); $sth->execute($date1,$date2); my $count=0; while (my @arr = $sth->fetchrow_array){ $table .= qq!<tr valign="center" align="middle"> <td>$arr[5]</td> <td>$arr[8]</td> <td>$arr[1]</td> <td>$arr[6]</td> <td>$arr[7]</td> <td>$arr[2]</td> <td>$arr[3]</td> <td>$arr[4]</td> <tr>!; ++$count; } if ($count==0){ return $noMsg; } else { $table .= q!</table>!; return $table; } }
poj
  • Comment on Re: Missing right curly or square bracket at jsdisp.cgi line 178, at end of line syntax error at jsdisp.cgi line 178, at EOF
  • Download Code