in reply to /i regex modifier

while ( $users = $sth->fetchrow_array ) { if(param("username") =~ /$users/i) {
The problem you're running into is that $users is going to be a reference, not a scalar string value.

Assuming that the user is the first element in the array you just fetched, try   if ( param("username") =~ /$$users[0]/i ) { Bah. I was getting fetchrow_array() confused with fetchrow_arrayref() (Thanks, jwest).

So, add a print statement. What is in $users? What is in param("username")?

Regardless, take japhy's advice, and don't do this with a regex.