1

When I add use CGI::Session; to my cgi file, I get this error:

An error occurred while writing CGI reply

If I comment that line its working fine.

I am using cPanel to host my site. What is the reason for this error? Is this missing the CGI::Session module on the server of hosting service provider?

How to fix this issue?

Code:

#!/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

If i uncommenting the #use CGI::Session ; then its giveing error. i need to import that file because i want to use session variable. how to fix the issue?

Devesh Agrawal
  • 8,982
  • 16
  • 82
  • 131
  • We're going to need a lot more information in order to help you. Can you give us a (cut down) example of code which exhibits your problem? What is written to the web server error log? – Dave Cross May 31 '12 at 09:21
  • Please check my edits in the query. – Devesh Agrawal May 31 '12 at 09:34
  • 1
    Read the Web server's error log for detailed information. - From the [Stack Overflow Perl FAQ](http://stackoverflow.com/questions/tagged/perl?sort=faq): [How can I troubleshoot my Perl CGI script?](http://stackoverflow.com/questions/2165022/how-can-i-troubleshoot-my-perl-cgi-script) – daxim May 31 '12 at 10:01
  • Which webserver does your hoster use? When I googled the error message I only found nginx related pages. I'm not sure if that's important, but there might be an incompatibility (only guessing here). If the module was missing it would say so. Where's your `use strict; use warnings;` btw? – simbabque May 31 '12 at 11:12
  • I am not sure which web server they uses. I am using freehosting.com for the hosting. – Devesh Agrawal May 31 '12 at 11:57
  • As far as figuring out which web server you're using, try "curl -I http://www.yourwebsite.com" That will show you the headers, which *may* include something like "Server: Apache/2.2.14 (Ubuntu)". – oalders May 31 '12 at 15:07
  • if you can run your program from the command line. Do so: – Len Jaffe May 31 '12 at 18:28

1 Answers1

0

Since you are apparently not getting fatalsToBrowser as requested, you'll need to run the program form a command line and see where it gets.

Do so:

$ /usr/local/bin/perl yourscriptname

See what error messages you get.

I would use the debugger, to have control of the program in case the error is not really in CGI::Session.

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

Once we can see the true error message, we can help you fix the problem.

Len Jaffe
  • 3,442
  • 1
  • 21
  • 28