in reply to /i regex modifier

This is so the wrong approach to take. Why are you going through all a list of database results searching for a username? ASK THE DATABASE!
my $sql = q{SELECT username FROM db WHERE username=?}; my $sth = $dbh->prepare($sql); $sth->execute(param("username"));
Now, if there's a result, the username existed in the database. And if you want to compare in lowercase, there are SQL utilities to do that as well. Don't use a regex. You're going about this the wrong way.

_____________________________________________________
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: /i regex modifier
by Anonymous Monk on Jul 18, 2002 at 19:39 UTC
    sorry Im trying to say, if user is eq to one of the usernames in the dtabase then give a error, but it prints out this error if I do that.
    Quantifier follows nothing before HERE mark in regex m/? << HERE / at +/home/dtdynoco/public_html/admin1130/register.cgi line 30.
      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:??;

        $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