Fellow Monasterians,
I'm completely puzzled by behavior I haven't experienced when using placeholders and bind values. It's a though I need to quote values or something. What am I missing after years of successful use?
my $stmt = q/SELECT * FROM users WHERE username= ? AND password = ?/; my @bind = ( $username, $password ); # doesn't work my @bind = ( 'wilma', 'foobar' ); # works my $acct = $dbh->selectrow_hashref($stmt, undef, @bind );
Update: I'm updating this because I don't want anyone who might be new to DBI to stumble across this node and be misled. Turns out, it had something, not sure what, with a dicey connection to our web server. Sounds crazy, but for an hour before a crash, the posted code didn't work with scalars, only hard-coded values. The server went down, and after the reboot, the code worked has it has for years. Sorry to waste previous PM bandwidth on an bizarre anomaly.
In reply to Is there a need to escape bind values in DBI by bradcathey
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |