Hi all,I've been knocking my head against an error I get from $dbh->quote and I'm sure that I'm missing something obvious. I've just been looking at the same thing too long. Here's the environment
Perl 5.8.4 Mac OS 10.3.5 CGI::Application DBI DBD::mysql# here's the problem - Apache error log says "Error executing run mode 'make_authcode': Can't call method "quote" on an undefined value at XXXX/ASEP.pm line xxx
Each time I test the values $authcode, $reqname, $created_ip THEY HAVE VALUES. AUGGGGGGGHHHHH!
Here's the run mode that is called by rm=make_authcode. =item authcode_makeCreates an authorization code that can be used on one customer order. The code is stored in the authorize
table for future reference.
=cut
sub authcode_make {
my $self = shift;
my $session = $self->session;
my $q = $self->query();
my $dbh = $q->param( 'mydbh' );
my $error;
my $template = $self->load_tmpl( 'authresponse.tmpl.html' ) || "Could
not load template file.";
my $created_ip = $ENV{REMOTE_ADDR};
my $username = $session->param( 'username' );
my $authcode = makecode( 10 );
my $reqname = $q->param( 'reqname' );
if ( $username =~ m/(customauth|mgr1-sed|ed)/ ) {
# ->I put this test in to redirect values to the error page
# ->When I comment out the if statement the error page displays all
values as expected
if ( !defined $reqname &&
!defined $created_ip &&
!defined $authcode ) {
$error = "The person requesting authorization is required.\nreqname
- $reqname\nauthcode - $authcode\ncreated_ip - $created_ip\n";
}
unless ( $error ) {
# $authcode = $dbh->quote( $authcode );
# ->I tried manually quoting the values to see if it was something in
DBI, but no luck.
$authcode = "'" . $authcode . "'"; $reqname = "'" . $reqname . "'"; $created_ip = "'" . $created_ip . "'"; my @value_array = ( $authcode, $reqname, $created_ip );my @insertField_array = qw( authcode username created_ip created_date );
my $value;# -> This is the original block I had used before moving to CGI::Application
# foreach $value ( @value_array ) {
# $value = $dbh->quote( $value ); # all columns are varchar so
they must be quoted
# }push @value_array, 'NOW()'; # add the NOW() function to get mysql timestamp value in second timestamp column
my $value_list = "(" . join(",", @value_array) . ")";
$value_list =~ /(.*)/;
$value_list = $1;
my $field_list = "(" . join(",", @insertField_array) . ")";
my $sql = "INSERT INTO authorize $field_list VALUES $value_list";
my $sth;
$sth = $dbh->prepare( $sql ) or die "Could not prepare authorization
insert -$sql- " . $sth->errstr();
$sth->execute() or die "Could not execute authorization insert
-$sql- " . $sth->errstr();
$sth->finish;
$template->param( 'reqname' => $reqname,
'authcode' => $authcode
);
}
} else {
$error = "Authorization needed to access this area.";
}
if ( $error ) {
$session->param( 'error' => $error );
my $newurl = '../cgi-bin/asep.cgi?rm=error';
$self->header_type('redirect');
$self->header_props( -url => $newurl );
return "Redirecting to $newurl";
} else {
return $template->output;
}
}
Maybe one of you can spot something obvious.
Thanks
Ed Pigg
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/suppressed/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.