in reply to GD module stops working

I'll try to give some more info. Perl version is 5.6.1, build 626 from Activestate. I am running PWS v4, build 1381. The new code that seems to make my program crash after being run about 4 times:

use GD; use GD::Graph; use GD::Graph::lines; use GD::Graph::pie; use GD::Graph::bars; use GD::Graph::colour; $field = $inputs{"field"}; $query = "SELECT $field FROM system_info"; print "<font size=-1>Query performed: $query<p>"; ## BEGIN DB ACCESS ## # Make a database handle $dbh = DBI->connect('dbi:Oracle:server', 'username', 'pass',) || d +ie "Database connection not made $DBI::errstr"; # Make a statement handle $sth = $dbh->prepare($query); $sth->execute; $i=0; while (@data=$sth->fetchrow_array()) { @array[$i]=$data[0]; $i++; } # Sort the array @array = sort {$a cmp $b} @array; $a=0; $b=0; $array_length = scalar(@array); print "Generating a graph for $array_length machines. Please wait +..."; # Create an associative array for all entries and the number of ti +mes in database while ($a < $array_length) { $b = $a + 1; if ($array[$a] =~ $array[$b]) { $count{$array[$a]}++; } $a++; } #### Start Graph Stuff @keys = keys(%count); @values = values(%count); @graphdata = ([@keys],[@values]); $num_graph_columns = scalar (@keys); $width=$num_graph_columns * 30; if ($width < 450) { $width=450; } $graph = GD::Graph::bars->new($width, 500); $graph->set( x_label => "$field", y_label => "number", title => "Graph of $field", bar_spacing => 6, shadow_depth => 4, shadowclr => 'dred', transparent => '1', x_labels_vertical => '1', show_values => '1' ); $graph->set_title_font('C:/winnt/fonts/arial.ttf', 18); $graph->set_x_axis_font('C:/winnt/fonts/arial.ttf', 8); $graph->set_y_axis_font('C:/winnt/fonts/arial.ttf', 8); $graph->set_y_label_font('C:/winnt/fonts/arial.ttf', 12); $graph->set_x_label_font('C:/winnt/fonts/arial.ttf', 12); $graph->plot(\@graphdata); open(OUTPUT, ">../wwwroot/chart.jpg") or die "Can't open chart.jpg +: $!\n"; binmode OUTPUT; print OUTPUT $graph->gd->jpeg(); close(OUTPUT); print "<p><center><img src=../chart.jpg><BR><BR><BR><font size=-2> +<table border=1 width=25%>"; foreach (keys(%count)) { print "<tr><td><font size=-1>$_</td><td><font size=-1>$count{$ +_}</td></tr>"; } print "</font></table>";
This code works, and I can display 4 or 5 graphs, but then the entire program stops responding. No error messages except: 'C:\Inetpub\scripts\webdb.cgi' script produced no output

If run from the command line the program runs correctly, with no errors. However, when run from the command line it never calls this method. It just checks the syntax. Any ideas?
Thanks, Kevin

Replies are listed 'Best First'.
Re: Re: GD module stops working
by Jouke (Curate) on Jul 24, 2001 at 16:53 UTC
    It's still very hard to make sensible comments, but I'll give it a try:
    • First piece of advice: add  use strict; at the top of your script, and add -w after the shebang (#!).
    • I get the feeling something is missing from the beginning, since you're starting with $field = $inputs{"field"};
    • You say that it dies without doing anything. That means it does not reach the part where you're creating the graphs themselves, since that's the first unconditional 'print' you're using (print "Generating a graph for $array_length machines.  Please wait...";)
    • This means your script probably has a problem with the connection to the Oracle database. Could it be that your database is very busy? Could it be that the response from the database is so slow that the script times out? Could it be you're receiving so much data that it takes too long for the data to arrive that PWS eventually kills the CGI script?
    Just my EUR 0.02.

    Jouke Visser, Perl 'Adept'
    Using Perl to help the disabled: pVoice and pStory
      Thanks for your advice Jouke. I don't think it has to do with the Oracle connection. I'm beginning to think that it is my web server. The graphs will display about 5 times, then on the 6th it will display Generating a graph for $array_length machines. Please wait... and it will appear to be loading the image and then stops loading the page. Then, no cgi scripts will work. Even other scripts that do not attempt to access the database won't load. Its as if the web server does not want to process any cgi scripts. Currently I have my registry pointing to perlis.dll, I might change it to perl.exe %s. It will be slower, but maybe it will work. And yes, there was some crap before the part of the code I posted, but nothing other than some beginning crap to get variables and print html headers.

      Thanks, Kevin