Bad Word Blocker - ERRORS

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Locked
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Bad Word Blocker - ERRORS

Post by tecktalkcm0391 »

I can't figure this out:

I keep getting the message:
Notice: Array to string conversion in /home/public_html/user.php on line 123

And were I the $bword[] is it just comes up with array, or if i use print_r() it comes up with:
Array ( [0] => ass [1] => * )


Also if the bad word is word, I get bad instead of word.

Code: Select all

$username_bad_check = $username;
$username_bad_check = strtolower($username_bad_check);
$badwords = array();
	$badwords[] = array('bad', ' * ');
	$badwords[] = array('word', ' * ');
array_change_key_case($badwords,CASE_LOWER);
/*$username_bad_check = implode("\r\n", $username_bad_check); */
foreach ($badwords as $bword) 
{ 
	  if (str_replace($username_bad_check, $badwords, $bword)){
	echo "OH NO YOU DID'T. We have found a bad word in your username! You may have put something bad in by mistake, but remember if you use bad words* on our site.<br><b>Your username can not contain the word: </b>" .  $bword[] . "<br><br><br><Br>*The term \"Bad Word\" refeers to a curse words, an explicit words, or any other inappropriate word, or word we find to be inappropriate." ; 
	exit;
    } 
}
Any help?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

This doesn't need a new thread.
Locked