I have the following HTML + PERL code for connecting to the SQLite Database and retrieving a value, incrementing it, and updating this new value in the database. However, my code is giving an Internal Server Error when ran on browser. I'm using Apache Server. The error log tells me to check my html code but there's nothing wrong with it. Please help:
<html>
<body>
<form action="/cgi-bin/a.pl" method="POST">
<input type="submit" value="Visit"/>
</form>
</body>
</html>
#!C:/Perl/bin/perl.exe
use DBI;
use strict;
use CGI;
my $cgi = CGI->new();
my $driver = "SQLite";
my $database = "my.db";
my $dsn = "DBI:$driver:db:$database";
my $userid = "";
my $password = "";
my $dbh = DBI->connect($dsn, $userid, $password) or die $DBI::errstr;
my $sth = $dbh->prepare("SELECT cnt from VISITORS");
my $rv = $sth->execute() or die $DBI::errstr;
my @row = $sth->fetchrow_array();
my $nov = $row[0];
$nov++;
$dbh->do('UPDATE VISITORS SET NOV = ? WHERE NOV = ?', undef, $nov, $nov-1);
$dbh->disconnect();
print $cgi->header('text/html');
print "No. of visitors = ". $nov . "\n";
Aucun commentaire:
Enregistrer un commentaire