J.J. wrote:
> Andy Hassall wrote:
>>> I had a line:
>>> $emailq = $dbh->quote($in{'email'});
>
>>  What was it doing? Examples of input and output data?
>>  It doesn't look like you're passing it a hash anyway, you're just
>> passing it a scalar that is an element of a hash.
>
> Er, bad wording. Meant a hash element. :-)
>
> In the above case, $emailq would be NULL. $in{'email'} is already
> tested at this point and is definitely not NULL (run through a
> subroutine that checks for proper e-mail address syntax).
>
> But:
>>> $email = $in{'email'};
>>> $emailq = $dbh->quote($email);
>  - or -
>>> $emailq = $dbh->quote("$in{'email'}");
> # added " quotes around the hash element.
>
> would both give a correctly 'quoted' variable.
>
> I've now got everything changed to one of those latter two examples,
> but I'm mainly wondering why the first example wasn't working.
> Couldn't find anything on this in documentation or googling, unless I
> missed it.

Again - examples of input and output data please?
As far as I know there's no way quote() could even tell if it was receiving
a scalar that happened to be a hash element even if it wanted to.

#!perl -w
use strict;
use DBI;

my $dbh = DBI->connect('dbi:mysql:database=testdb;host=server',
         'andyh', '******',
         { RaiseError => 1, AutoCommit => 0 });

my $email = '[EMAIL PROTECTED]';
my %hash = (email => $email);

print $dbh->quote($email) . "\n";
print $dbh->quote($hash{'email'}) . "\n";
print $dbh->quote("$hash{email}") . "\n";

$dbh->disconnect;

__END__

$ perl quote.pl
'[EMAIL PROTECTED]'
'[EMAIL PROTECTED]'
'[EMAIL PROTECTED]'


-- 
Andy Hassall ([EMAIL PROTECTED]) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)

Reply via email to