I have a language check on my website that will compare the user's input with bad words that are stored in a table. Eregi or strpos works if I specify the word I'm searching for -
$test = strpos($thestring, "badword"); //this works.
if(eregi("badword", $thestring"){}//this works.
I need to use a query to compare the badwords that are stored in a table, so I wrote the following:
$sql="
select *
from words
";
$result = mysql_query($sql) or die (mysql_error());
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$test = strpos($thestring, $row['word']);
or
if(eregi($row['word'], $thestring))
}
The query works correctly, that is for sure. I've tried added quotes and assigning the $row['word'] to a variable, nothing works after hours of trying. I just want to see if the bad word is found in the string. Any ideas?
Thank you.