【发布时间】:2014-01-12 13:23:41
【问题描述】:
当我运行我的 CGI Perl 脚本时,我遇到了一个错误。
No such file or directory: exec of '/opt/lampp/cgi-bin/filename.cgi failed
我在 linux 环境中使用 XAMPP,这个文件存在于根文件夹中。
我的代码:-
#!/usr/bin/perl
use diagnostics;
use DBI;
use strict;
use warnings;
use CGI qw(:standard);
my $driver = "mysql";
my $database = "mysql";
my $dsn = "DBI:$driver:database=$database";
my $userid = "root";
my $password = "password";
my $dbh = DBI->connect("dbi:mysql:dbname=mysql", "root", "password",
{ AutoCommit => 0,RaiseError => 1}, )
or die ("Couldn't connect to database: ") , $DBI::errstr;
my $sth = $dbh->prepare("select * from userrecords");
$sth->execute();
print "Content-type:text/html\r\n\r\n";
print "<a href='/Index.html'>-> Home Page</a>";
print "<table style='border-style: double; width: 30%;' border='1' cellpadding='1' cellspacing='1'>\n";
print "<td style='font-weight: bold' align='center'>Name</td><td style='font-weight: bold' align='center'>Address</td>
<td style='font-weight: bold' align='center'>City</td><td style='font-weight: bold' align='center'>Occupation</td><td style='font-weight: bold' align='center'>Age</td>\n";
while(my($ID,$name,$address,$city,$occupation,$age) = $sth->fetchrow_array) {
print " <tr>\n";
print " <td>$name</td>\n";
print " <td>$address</td>\n";
print " <td>$city</td>\n";
print " <td>$occupation</td>\n";
print " <td>$age</td>\n";
print " </tr>\n";
}
print "</table>\n";
$sth->finish();
$dbh->disconnect();
请帮忙 提前谢谢!!!
【问题讨论】:
-
这看起来像一个 apache/xampp 错误,所以也许你应该添加这些标签。当然,它看起来就像网络服务器在您所说的位置找不到您的
filename.cgi。所以也许检查一下?