I wanna check $username to make sure that it only contains letters and numbers and a underscore, anythig else giver error();
error() unless $username =~ m< ^ \w+ \z >x;
Is there in way in SQL to select a row by random, so if it havd 1000 rows it picked row 200.There isn't a generic way to pick a random row in MySQL, but if you've got a primary key which is an integer and you know the amount of rows you've got then you can just pick a random number and SELECT from that e.g
my $sth = $dbh->prepare( 'SELECT some,rows FROM your_table WHERE id = ?' ); $sth->execute( int rand $dbh->selectrow_array('SELECT MAX(*) FROM your_table') );
_________
broquaint
update: changed COUNT to MAX (thanks to UnderMine for that one)
In reply to Re: Username regex, MYSQL random
by broquaint
in thread Username regex, MYSQL random
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |