1

当我添加use CGI::Session;到我的 cgi 文件时,我收到此错误:

写入 CGI 回复时出错

如果我评论那条线它工作正常。

我正在使用 cPanel 来托管我的网站。这个错误的原因是什么?这是否缺少CGI::Session托管服务提供商服务器上的模块?

如何解决这个问题?

代码:

#!/usr/local/bin/perl 
use HTML::Template; 
use DBI;
use CGI;
use CGI::Carp qw/fatalsToBrowser warningsToBrowser/;
#use CGI::Session ;

#send the obligatory Content-Type
print "Content-Type: text/html\n\n"; 

$user = '*******';
$password = '********';

#$session = CGI::Session->load();
#$q = new CGI;

$db_handle = DBI->connect ('DBI:mysql:database=amdvsfre_justclick',$user,$password) 
or die "Couldn't connect to database: $DBI::errstr\n";

#set the value of SQL query

$sql_query = "SELECT t1.request_id, t1.request_message, t2.user_name, t2.user_city , COUNT(t3.request_id), t1.request_date, t1.request_time
FROM requests t1 INNER JOIN users t2 ON t1.user_id = t2.user_id
LEFT JOIN responses t3 ON t1.request_id = t3.request_id
GROUP BY t1.request_id desc" ;

 ...
 ...
 passing the query result in template file, so that it can be displayed on the browser

如果我取消注释 #use CGI::Session ;然后它给出错误。我需要导入该文件,因为我想使用会话变量。如何解决这个问题?

4

1 回答 1

0

由于您显然没有按照要求获得 fatalsToBrowser,因此您需要从命令行运行程序并查看它的位置。

这样做:

$ /usr/local/bin/perl yourscriptname

查看您收到的错误消息。

我会使用调试器来控制程序,以防错误不在 CGI::Session 中。

$ /usr/local/bin/perl -d yourscriptname

一旦我们可以看到真正的错误消息,我们就可以帮助您解决问题。

于 2012-05-31T18:32:47.493 回答