Ok Perl Monks, I really could use your wisdom here :o)
I've created a site in perl and MySQL. when my visitors
register, I have it check a database table of obscene usernames and return "bad" if it's in there.
Here is how I am searching it:
$sth = $dbh->prepare (qq{ SELECT * FROM `forbidden_usernames` WHER
+E `f_user` LIKE ? });
$sth->execute("$str");
$row = $sth->fetchrow_hashref();
$sth->finish();
if ($str =~ /$row->{f_user}/i) {
return("bad");
}
Ok, now my problem is that if I even try to use my name as a username it is returning it as bad.
I did have a wildcard in the
$sth->execute("$str"); like this:
$sth->execute("%$str%");
I thought that might have been the problem, but it was not. when I took out the wild cards on both sides of it, It is still saying any username is bad.
However, if I just take out the LIKE and make it a = then it won't get something like asshole when I only have ass in the database and visaversa.
Is there a "contains" like Perl's =~ for MySQL, that you know of in your infinite wisdom?
Or should I go ask on a MySQL board, if I can find one?
thx,
Richard
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.