Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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

In reply to Perl and MySQL - performing a search... by powerhouse

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (5)
As of 2024-04-24 08:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found