Your CGI is called for each request and then terminated. There is no way
to make the DBI handle persistant. (And by the way, if hiding the handle
in a hidden field would work, you would create a security hole large
enough for a 747.)
You need a permanently running server for a persistant handle. Think
about using FastCGI, Apache::Registry or, if you just have started your
application, a mod_perl handler.
Alexander
Mary Anderson wrote:
Hi all,
I am writing a Web app in perl/cgi/dbi which (1) attempts to verify
logins by checking against database user passwords, and (2) follows good
dbi practices by logging the user in once at the beginning of the session
instead of logging in immediately prior to accessing the database.
I am running afoul of CGI parameter passing conventions. I do( and
find) the following
use CGI "standard";
use DBI;
my $dbh;
if ($condition){
$dbh = $DBI:connect($connectionString, $login, $password);
# find connection is successful at this poing
sub fubar{
my $sth=$dbh->prepare($cmd);
# find that $dbh is undefined.
I have tried passing the handle in as a ref parameter, using $dbhRef = /*dbh
(maybe this one was done incorrectly) and tried passing a $dbhRef as a
value on a hidden textfield. None of these work. I tend to get
"not an array" when I try to do $$dbhref to dereference the handle.
Is there any way to make the handle persist?
Would I have this trouble if I used Mason?
Thanks in advance,
Mary Anderson
--
Alexander Foken
mailto:[EMAIL PROTECTED] http://www.foken.de/alexander/