in reply to Re^5: Quick 'Quote' DBI Question
in thread Quick 'Quote' DBI Question

IIRC you will have to put the "%" sign in the the argument to execute() yourself, since placeholders only handle quoting, they don't try to parse anything else:

$yi->execute($year,"%".$ssn,$name);
Note that that also means you have to be careful about what's in $ssn - if someone manages to put "_" or "%" characters in $ssn the query might no longer do what you think it should.

Replies are listed 'Best First'.
Re^7: Quick 'Quote' DBI Question
by Trihedralguy (Pilgrim) on Apr 06, 2007 at 15:05 UTC
    Sweet! I have it where SSN can be numbers only by doing something like:
    if ($ssn =~ /^[0-9]*\z/ && $year =~ /^[0-9]*\z/) {
      ooops. update The "oops" is on me, that is. Missed that there are supposed to be only four digits.

      That leaves you needing a small fix to your regex to deal with cases when the SSN is entered with hyphens, as

      123-45-6789

      However, you might still want to make sure that's the case, by using a numeric quantifier instead of the deathstar

      s/if ($ssn =~ /^[0-9]*\z/if ($ssn =~ /^[0-9]{4}\z/
        Not a problem, is the last four digits only.