我有以下HTML + PERL代码,用于连接到SQLite数据库并检索值,递增值以及更新数据库中的新值。但是,我的代码在浏览器上运行时会给出Internal Server Error
。我正在使用Apache Server。错误日志告诉我检查我的HTML代码,但它没有任何问题。请帮忙:
<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";
答案 0 :(得分:0)
我的错误是我没有创建表,因此无法识别表名,插入语句失败。