in reply to GD module stops working
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 outputuse 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>";
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 | |
by kbradford (Novice) on Jul 24, 2001 at 17:09 UTC |