Soldato
- Joined
- 12 Jan 2006
- Posts
- 2,547
I have run out of ideas , basically when i run this script from the console it is fine outputs the right html.
But as soon as i run it from a browser i get errors :/
the script is essentially the same as one called Named Artist, with the only difference being the table it refers to in the database.
Now the SQL Query works
the Perl script works in the console
the HTML is identical to a working version bar refering to a different perl script
For the sake of testing i hard coded some data to test if the tables work.
Code for my html page:
Code for my perl script
Purposfully left out the stuff to setup the enviroment
Output in console:
Output when using webpage
Its not a administrative problem as all my pervious pages work fine
Any help would be much appreciated
But as soon as i run it from a browser i get errors :/
the script is essentially the same as one called Named Artist, with the only difference being the table it refers to in the database.
Now the SQL Query works
the Perl script works in the console
the HTML is identical to a working version bar refering to a different perl script
For the sake of testing i hard coded some data to test if the tables work.
Code for my html page:
Code:
<html>
<head>
<title>Select a player form</title>
</head>
<body>
<h2>Select a player form</h2>
<FORM METHOD="POST" ACTION="http://www2.wmin.ac.uk/~w0402086/cgi-bin/TotalSales.pl">
<p><h3>
Enter the name of a player to obtain their full details
</h3></p>
<center>
<p>Day
<input type="text" name="Day" size="2" maxlength="2"/>
</p>
<p>
Month<input type="text" name="Month" size="2" maxlength="2"/>
</p>
<p>
Year<input type="text" name="Year" size="2" maxlength="2"/>
</p>
<input type="submit" name="Sub" value="Send query"/>
<input type="reset" value="Reset Form"/>
<input type="hidden" name="HiddenName" value="selectform.html"/>
</center>
</form>
</body>
</html>
Code for my perl script
Purposfully left out the stuff to setup the enviroment
Code:
if ($ENV{'REQUEST_METHOD'} eq "POST") {
read(STDIN,$buffer,$ENV{'CONTENT_LENGTH'});
} else {
$buffer = $ENV{'QUERY_STRING'};
}
@pairs= split(/&/,$buffer);
foreach $pair (@pairs) {
($name,$value) = split(/=/,$pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
$contents{$name} = $value;
}
#$Day = $contents{'Day'};
#$Day =~ s/$regexp//g; # remove suspect chars
#$Month = $contents{'Month'};
#$Month = =~ s/$regexp//g; # remove suspect chars
#$Year = $contents{'Year'};
#$Year =~ s/$regexp//g; # remove suspect chars
$Day = '12';
$Month = '12';
$Year = '03';
my $dbh = DBI->connect("dbi:Oracle:ORA8", "username","password")
or die "Cannot connect: " . $DBI::errstr;
my $sql = "SELECT SaleDate /*, COUNT(*) Total_Sales*/
FROM Sales
WHERE SaleDate = to_date('$Day/$Month/$Year' ,'DD/MM/YY')
GROUP BY SaleDate";
my $sth = $dbh->prepare($sql) or die "Cannot prepare: " . $dbh->errstr();
if ($sth->execute()) {
my @data;
my $count = 0;
print "Content-Type: text/html;charset=ISO-8859-1\n\n";
print "<html>\n<head>\n<title>Recording Search</title>\n</head>\n";
print "<body bgcolor=\"peachpuff\"><h1>Artist's Recordings</h1>\n";
print "\n<TABLE BORDER=1 ALIGN=CENTER>";
print"<tr><th>Artist's Name</th></tr>\n";
while (@data =$sth->fetchrow_array())
{ ++$count;
print "<tr bgcolor=ffddbb>\n";
foreach my $element (@data) {
print "<TD>$element\n</TD>";
}
#print"<br></br>";
print"</TR>";
}
print "</TABLE>";
}
print "</body>\n</html>\n";
$sth->finish();
$dbh->disconnect();
Output in console:
Code:
58 tiger% perl TotalSales.pl
Content-Type: text/html;charset=ISO-8859-1
<html>
<head>
<title>Recording Search</title>
</head>
<body bgcolor="peachpuff"><h1>Artist's Recordings</h1>
<TABLE BORDER=1 ALIGN=CENTER><tr><th>Artist's Name</th></tr>
<tr bgcolor=ffddbb>
<TD>12-DEC-03
</TD></TR></TABLE></body>
</html>
Output when using webpage
Code:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Any help would be much appreciated