in reply to Re: DBI Problem
in thread DBI Problem

Thanks for the links. You knew what to search for. I search for the "i can't work out... and did not find what you found.

Sounds just like my problem.

I inserted code before each of the two ExecuteQuery calls:

warn("1st call Connection-database handle: '$dbh' dsn: '$dsn'");

and

warn("2nd call Connection-database handle: '$dbh' dsn: '$dsn'");

And got the following in the error log:

Fri Sep 29 17:28:23 2017 manage_users.cgi: 1st call Connection-database handle: 'DBI::db=HASH(0x2928270)' dsn: 'dbi:mysql:database=jalamior_assoc_mgr;host=localhost' at /home/jalamior/www/httpsdocs/cgi-bin/lib/perl/manageusers.pm line 625.

Fri Sep 29 17:28:23 2017 manage_users.cgi: 2nd call connection-database handle: 'DBI::db=HASH(0x2928270)' dsn: 'dbi:mysql:database=jalamior_assoc_mgr;host=localhost' at /home/jalamior/www/httpsdocs/cgi-bin/lib/perl/manageusers.pm line 666.

(in cleanup) Can't connect to data source '' because I can't work out what driver to use (it doesn't seem to contain a 'dbi:driver:' prefix and the DBI_DRIVER env var is not set) at /usr/local/lib/perl5/site_perl/5.8.8/CGI/Session/Driver/DBI.pm line 26

I don't see where "it can't see the driver information.." So this must mean that something happens downstream in the call to executequery. Now back to square one as best I can see. I added $session->flush() with no effect.

sub ExecuteQuery { my ($SQL) = @_; my $sth = $dbh->prepare($SQL) or die $dbh->errstr; $sth->execute() or die $dbh->errstr; # $dbh->commit or die $dbh->errstr; # my $sth = $dbh->prepare($SQL) || ErrorMessage($SQL); # $sth->execute() || ErrorMessage($SQL); return $sth; $session->flush(); }

Session opened for all routines in this .pm

sub OpenSession{ my ($dbh, $sid)= @_; $session = new CGI::Session("driver:MySQL", $sid, {Handle=>$dbh, Lo +ckHandle=>$dbh}); return $session; }

Can you see a problem with these?

Replies are listed 'Best First'.
Re^3: DBI Problem
by huck (Prior) on Sep 30, 2017 at 00:07 UTC

    Putting the flush after the return is less than useless

    i suspect the flush belongs in OpenSession

    It seems to be a problem in the destructor, when the database has already been closed but the session has not been flushed

      That flush is before the next call to execute. That was the way it was in the examples at the links.

      Why is it useless? It still flushes the session.

        Have you read return? Everything after a call to return is useless

        Guess it does not. When I moved it ahead of return, pops up error

        Can't call method "flush" without a package or object reference at /home/jalamior/www/httpsdocs/cgi-bin/lib/perl/manageusers.pm line 198.