in reply to Re^2: Getting mysql data into gd
in thread Getting mysql data into gd
Hello, shanta.
An old-fashioned, brute-force way to troubleshoot a problem is to check what is happening at key points in the program. This helps ensure the data you think you should be getting and using is what you are actually getting and using.
For example, this code shows the data returns after every step. This is likely to be helpful in isolating the problem:
#!/usr/bin/perl use strict; use warnings; use DBI; use GD::Graph::Data; use GD::Graph::bars; # do DBI things, like connecting to the database, statement # preparation and execution # Don't forget to print the results of your various DBI commands. # Your open(), for example, might not be working correctly. my $sql = "SELECT time, mastuntemp, LineTemp, spargtemp FROM brew_temp +_tb WHERE sitename = 'Brew' AND batchnumber = '$batchnumber' ORDER BY + time"; print "DEBUG: \$sql = \"$sql\"\n"; my $data = GD::Graph::Data->new(); print "DEBUG: \$data = \"$data\"\n"; my $sth = $dbh->prepare($sql); print "DEBUG: \$sth = \"$sth\"\n"; if (!$sth->execute()) { die "Error: ". $sth->errstr ."\n"; } my @row; while (@row = $sth->fetchrow_array) { print "DEBUG: \@row = \"@row\"\n"; my $rowidx = 0; foreach my $rowdata (@row) { print " [$rowidx] = \"$rowdata\"\n"; $rowidx++; } $data->add_point(@row); } exit;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Getting mysql data into gd
by shanta (Novice) on Sep 03, 2017 at 17:31 UTC | |
by poj (Abbot) on Sep 03, 2017 at 19:28 UTC |