Eric J. Roode on 27 Jan 2004 02:15:03 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: perl DBI question


----- Original Message ----- 
From: "Malcolm" <mjhlists-phl-pm@liminalflux.net>
To: <phl@lists.pm.org>
Sent: Monday, January 26, 2004 3:45 PM
Subject: perl DBI question


> Greetings all,
>
> I've been having a problem with the 'quote' function in DBI that I still
> haven't been able to resolve, so I thought I'd ask in case I'm missing
> something obvious.
>
> The code in question looks something like:
>
> my $dbh =DBI->connect( 'dbi:mysql:database=$db', $user, $passwd);
> my $hash = {'some'=>'data'};
> my $quoted = $dbh->quote($hash->{'some'});
>
> at which point $quoted is undefined.
>
> However:
>
> my $dbh =DBI->connect( 'dbi:mysql:database=$db', $user, $passwd);
> my $hash = {'some'=>'data'};
> my $temp = $hash->{'some'};
> my $quoted = $dbh->quote($temp);
>
> results in $quoted having the correct value ('data');
>
>
> (This is all running under Mason/apache/mod_perl, in case it makes any
> difference).

Sheer guess: you're fallnig victim to mod_perl's (specifically,
Apache::Registry's)
well-known 'my' variable problems.

Try changing all of the relevant variables to package globals (via 'use
vars',
'our', or '$main::' -- choose your poison) and see if the problem persists.

Without running any tests, your code looks good to my eyeballs.

HTH,
Eric

-
**Majordomo list services provided by PANIX <URL:http://www.panix.com>**
**To Unsubscribe, send "unsubscribe phl" to majordomo@lists.pm.org**