in reply to Re: Re: /i regex modifier
in thread /i regex modifier

You do NOT want to use a regex. A regex does not test for equality. If you want EQuality, use eq. You even used "eq" as a word in your node!

Apparently, $users starts with a "?". But this is pointless. Don't use a regex. Do not.

_____________________________________________________
Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a job (NYC-area)
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Replies are listed 'Best First'.
Re: Re: Re: Re: /i regex modifier
by Anonymous Monk on Jul 18, 2002 at 19:47 UTC
    $sth = $dbh->prepare("SELECT username FROM users"); $sth->execute; while ( $users = $sth->fetchrow_array ) { if (param("username") =~ /$users/) { error("Username already exists, please make a different one"); } }
    Can someone make this so it will check from the datbase then
      I already showed you. I'll repeat myself, though it pains me to do so.
      $sth = $dbh->prepare( "SELECT username FROM users WHERE username=?" ); $sth->execute(param("username")); if ($sth->fetchrow_array) { error("The username already exists."); }

      _____________________________________________________
      Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a job (NYC-area)
      s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;