Click to See Complete Forum and Search --> : Incomplete page loading up


dotcomguru
04-29-2005, 03:02 PM
Hi Friends,

I have this Perl program on IIS server. I am writing a simlpe perl program that accepts user input, stores value in database and generates another HTML (questionnaire form) page. The code uses DBI to connect to MS SQL Server. Works fine on dev environment - fails on production :(

Sometimes it loads up an incomlpete page as shown in the screen shot. I have a feeling its more of a settings issue then code - but not sure.

This mostly happens when I go back and fort a few times using theback button.

Any of you experienced this before. This problem is a real nagging pain in my...

Thanks in advance for you help.

Nedals
04-29-2005, 07:15 PM
My guess, assuming it stops a No 7...
You have a database query error that's not being reported..

Add use CGI::Carp(qw/fatalsToBrowser/); near the top of your script and
Add {RaiseError=>1,PrintError=>0} into your connect statement.

That's for a Linux server. So something similar for IIS

dotcomguru
07-26-2005, 07:19 PM
Problem Solved. Phew! :D

Just put this line of code
$|=1;
at the top of the program. Perl buffers it output and then sends it out in bunches. By writing this code, perl will not buffer the output but keeps sending it along with the flow.

Hope this helps many others who were stuck in the code, like me.

Thanks.

Jeff Mott
07-26-2005, 08:47 PM
dotcomguru, when a Perl program finishes anything that is left in the buffer is printed. Your tweak may have gotten your text out before something crashed, but most likely something is still crashing. All you've done is to find a clever (and unreliable) way to ignore it. So let's try to really solve the problem.

You said that you get an incomplete page sometimes? Is there some pattern to when this problem occurs? Or does it appear random?

In addition to what Nedals suggested you add to your code, add this as well.use warnings FATAL => 'all';Let us know what messages you get.

If your program isn't extremely large then you could attach it as well.

Nedals
07-26-2005, 10:21 PM
If, and I'm guessing, you have an SQL query error, you may want to take a look for this little gotcha that has caught me a couple of times.

SELECT .... FROM.... WHERE ... AND id=$some_variable

my $some_variable = ''; (or undefined)
In your program it may get set, but the conditions are such that it's not. The SQL query will 'kick out' an error and stop continued processing.

One way to circumvent this problem is to add the following just before your SQL query..
$some_variable = 0 if (!$some_variable);
This will now simply skip this condition (assuming you don't have an id=0) and continue processing.

Just a thought!