in reply to DBI quote: invalid number of parameters
DBI is throwing an error because you are not passing anything to quote. The code you posted looks like it is passing something to quote; however, param('something') can retrun an empty list when called in list context. So what you basically end up doing is $dbi->quote(), and DBI throws an error to protect you from yourself.
So, to get it to do what you want, you can do a $dbi->quote(scalar(param('username'))), or maybe $dbi->quote(param(('username') or undef)).
Also you might want to try using placeholders instead of using quote() on each value. While placeholders will not get you around the 'param returning an empty list problem', placeholders end up being much cleaner. Something like this:my $sth = $dbh->prepare("INSERT INTO member (nickname, password, first +_name, last_name, email, country, homepage, im_type, im_id, info) VAL +UES (?,?,?,?,?,?,?,?,?,?)"); $sth->execute( map {scalar(param($_))} qw(username password1 firstname lastname email imtype imid info ) );
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: DBI quote: invalid number of parameters
by Baiul (Acolyte) on Feb 23, 2003 at 23:54 UTC | |
by Baiul (Acolyte) on Feb 24, 2003 at 04:41 UTC |
In Section
Seekers of Perl Wisdom