RE: Make database handle persist in CGI/DBI application?
- From: ctantalo@xxxxxxxxxxx (Christopher G Tantalo)
- Date: Thu, 23 Feb 2006 12:40:18 -0500
I have run into this myself. The scope of dbh doesn't exist in your sub
function. I make the my $dbh declaration to an our $dbh. This seems to
do the trick for me.
Chris
-----------------------------------------------
Just Your Friendly Neighborhood
_SPIDEY_
-----Original Message-----
From: Mary Anderson [mailto:mfanderson@xxxxxxxxxxx]
Sent: Thursday, February 23, 2006 12:16 PM
To: dbi-users@xxxxxxxx
Subject: Make database handle persist in CGI/DBI application?
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
-----------------------------------------
The information contained in this message may be privileged,
confidential, and protected from disclosure. If the reader of this
message is not the intended recipient, or any employee or agent
responsible for delivering this message to the intended recipient,
you are hereby notified that any dissemination, distribution, or
copying of this communication is strictly prohibited. If you have
received this communication in error, please notify us immediately
by replying to the message and deleting it from your computer.
Thank you. Paychex, Inc.
.
- Prev by Date: Re: Make database handle persist in CGI/DBI application?
- Next by Date: perl v5.8.0 DBI core on AIX 5.2
- Previous by thread: Re: Make database handle persist in CGI/DBI application?
- Next by thread: perl v5.8.0 DBI core on AIX 5.2
- Index(es):
Relevant Pages
|