in reply to SQL String Escape Special Characters

JZed's response is correct -- use placeholders (best way) or you're required to obey SQL syntax and single quote the values. Just an additional tip, though -- a simple debugging statement like this:
my $uname = 'leander@whatever.com'; my $sql = 'SELECT uname, pwd FROM login WHERE uname=' . $uname; warn $sql; # <====== would print: # SELECT uname, pwd FROM login WHERE uname=leander@whatever +.com # which is illegal SQL my $res = $dbh->selectall_arrayref($sql) || die $dbh->errstr;
would (could/should) of pointed the problem out as well.

Replies are listed 'Best First'.
Re^2: SQL String Escape Special Characters
by Joost (Canon) on May 25, 2005 at 23:10 UTC
      Good advice, but I think davidrw was just pointing out how the OP could see that the OP's method of concating the SQL string didn't even put in quotes at all.