perlquestion
ikkon
I am pulling information from a MySQL database one row at a time, then while looping through the table i am running a script that creates a pdf, on each row based on there info.
I loop through the first row and it works just fine, it gets to the second record and bails halfway through.
this is the error
<code>
Uncaught exception from user code:
Can't call method "new_obj" on unblessed reference at C:/Perl/site/lib/PDF/API2/Resource.pm line 66.
at C:/Perl/site/lib/PDF/API2/Resource.pm line 66
PDF::API2::Resource::new('PDF::API2::Resource::XObject::Image::PNG', 'undef', 'PxCBQ') called at C:/Perl/site/lib/PDF/API2/Resource/XObject.pm line 64
PDF::API2::Resource::XObject::new('PDF::API2::Resource::XObject::Image::PNG', 'undef', 'PxCBQ') called at C:/Perl/site/lib/PDF/API2/Resource/XObject/Image.pm line 65
PDF::API2::Resource::XObject::Image::new('PDF::API2::Resource::XObject::Image::PNG', 'undef', 'PxCBQ') called at C:/Perl/site/lib/PDF/API2/Resource/XObject/Image/PNG.pm line 62
PDF::API2::Resource::XObject::Image::PNG::new('PDF::API2::Resource::XObject::Image::PNG', 'undef', 'assets/VMwareTCOChart35.png') called at C:/Perl/site/lib/PDF/API2/Resource/XObject/Image/PNG.pm line 298
PDF::API2::Resource::XObject::Image::PNG::new_api('PDF::API2::Resource::XObject::Image::PNG', 'PDF::API2=HASH(0x2eb962c)', 'assets/VMwareTCOChart35.png') called at C:/Perl/site/lib/PDF/API2.pm line 1816
PDF::API2::image_png('PDF::API2=HASH(0x2eb962c)', 'assets/VMwareTCOChart35.png', '-lossless', 1) called at C:\WEB_ROOT\dbcall\VMwareTCODBReport.pl line 1032
main::setImage('assets/VMwareTCOChart35.png', 311.811023622047, 467.716535433071, 270, 225) called at C:\WEB_ROOT\dbcall\VMwareTCODBReport.pl line 358
</code>
I am not sure why its causing this error, any help would be great, here is the loop I am using minus the pdf code its too long.
<code>
#!/usr/bin/perl -w
BEGIN {
use CGI::Carp qw(carpout);
open(\*MYLOG, '>>', "VMwith-db.log") or
die("Unable to open perl.log: $!\n");
carpout(MYLOG);
}
use PDF::API2;
use PDF::Table;
use perlchartdir;
use DBI;
use MIME::Lite;
use strict;
use warnings;
use diagnostics;
use CGI qw(:standard);
use constant mm => 25.4/72;
use constant in => 1/72;
use constant pt => 1;
my %valueHash;
my %User_Preferences;
my $q = new CGI;
print $q->header( "text/plain" );
open( CONFIG, 'variables.conf' );
while (<CONFIG>) {
chomp; # no newline
s/#.*//; # no comments
s/^\s+//; # no leading white
s/\s+$//; # no trailing white
next unless length; # anything left?
my ($var, $value) = split(/\s*=\s*/, $_, 2);
$User_Preferences{$var} = $value;
}
close (CONFIG);
my $dbhost = $User_Preferences{"localhost"};
my $dsn = "dbi:mysql:$User_Preferences{\"dbName\"}:$dbhost";
my $db_user_name = $User_Preferences{"db_user_name"};
my $db_password = $User_Preferences{"db_password"};
my $dbh = DBI->connect($dsn, $db_user_name, $db_password);
my $selectState = qq{SELECT uid, fparams FROM vmware WHERE flag = 10};
my $sth = $dbh->prepare($selectState);
$sth->execute or die "Can't execute SQL statement: $DBI::errstr\n";
## search through the database - so we can run the pdf for every row
while ((my $key, my $row) = $sth->fetchrow_array()) {
my $workingFlag = qq{UPDATE vmware SET flag = 20 WHERE uid = $key};
$dbh->do($workingFlag) or die "Can't Update DataBase: $DBI::errstr\n";
my $fparams = join('', $row);
%valueHash = map split(/=/, $_, 2), split /\|\|/, $fparams;
#while( my($key2, $value2) = each(%valueHash)){
# print " KEY: $key2..... VALUE: $value2 \n ";
#}
#do PDF Stuff HERE ....
}#WHILE LOOP THROUGH THE db
warn"Data fetching terminated early by error: $DBI::errstr\n" if $DBI::err;
</code>