Forum Moderators: open
$query = mysql_query("SELECT count(*) FROM blacklist where LOCATE(keystroke_entry, LOWER('$firstname')) > 0");
if(!$query) {
#handle error
}
$row = mysql_fetch_array($query);
if($row[0] > 0) { // $firstname contains a blacklisted entry
#redirect to error page
}
For the life of me, I cannot figure out how to do this:
LOCATE(keystroke_entry, LOWER('$firstname' or '$lastname' or '$randombox')
I have tried the above query, replacing 'or' with ¦¦ and no luck.
I do not have much experience with locate() at all, but I've read up a bit about it and it appears as the bigger your table gets, the slower the results will be.
Is there a faster way to compare the form results against my database (using LIKE maybe? how could I do that?)
I am using php and mysql, not sure if it matters any.
$query_string = "SELECT count(*) FROM blacklist where LOCATE(keystroke_entry, LOWER('" . $firstname . "')) > 0 OR LOCATE(keystroke_entry, LOWER('" . $lastname . "')) > 0 OR LOCATE(keystroke_entry, LOWER('" . $randombox . "')) > 0";
$query = mysql_query($query_string);
...
this way you can also print the query string to make sure it is what you think it should be.
(i'm not a phper, but i think you need to do the string concatenation to get proper variable interpolation.)
I really have no idea what you mean about:
i think you need to do the string concatenation to get proper variable interpolation.
Once my table starts getting larger, this is going to lessen in performance?
Is there a more efficient way to get results, or is this the only way to pull it as I need it?