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

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.

Replies are listed 'Best First'.
Re: Re: Re: /i regex modifier
by japhy (Canon) on Jul 18, 2002 at 19:41 UTC
    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
        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:??;