【发布时间】:2012-06-01 02:32:47
【问题描述】:
当我将 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 ;然后它给出错误。我需要导入该文件,因为我想使用会话变量。如何解决这个问题?
【问题讨论】:
-
我们需要更多信息才能帮助您。你能给我们一个展示你的问题的(缩减的)代码示例吗?将什么写入 Web 服务器错误日志?
-
请检查我在查询中所做的修改。
-
阅读 Web 服务器的错误日志以获取详细信息。 - 来自Stack Overflow Perl FAQ:How can I troubleshoot my Perl CGI script?
-
您的主机使用哪个网络服务器?当我搜索错误消息时,我只找到了 nginx 相关页面。我不确定这是否重要,但可能存在不兼容(仅在这里猜测)。如果模块丢失,它会这样说。顺便说一句,你的
use strict; use warnings;呢? -
我不确定他们使用的是哪个网络服务器。我正在使用 freehosting.com 进行托管。