bad words filter integration
===

I am trying to integrate php bad words filter 
The input is taken through $_REQUEST['qtitle'] and $_REQUEST['question']
But I am failed to do so 

    $USERID = intval($_SESSION['USERID']);

    if ($USERID > 0)
    {
	$sess_ver = intval($_SESSION[VERIFIED]);
	$verify_asker = intval($config['verify_asker']);
	if($verify_asker == "1" && $sess_ver == "0")
	{
		$error = $lang['225'];
		$theme = "error.tpl";
	}
	else
	{
		$theme = "ask.tpl";
		STemplate::assign('qtitle',htmlentities(strip_tags($_REQUEST['qtitle']), ENT_COMPAT, "UTF-8"));
		STemplate::assign('question',htmlentities(strip_tags($_REQUEST['question']), ENT_COMPAT, "UTF-8"));
		if($_REQUEST['subform'] != "")
		{
			$qtitle = htmlentities(strip_tags($_REQUEST['qtitle']), ENT_COMPAT, "UTF-8");
			$question = htmlentities(strip_tags($_REQUEST['question']), ENT_COMPAT, "UTF-8");
			$category = intval($_REQUEST['category']);

   
			if($qtitle == "")
			{
				$error = $lang['3'];
			}
			elseif($category <= "0")
			{
				$error = $lang['4'];
			}
			else
			{
				if($config['approve_stories'] == "1")
				{
					$addtosql = ", active='0'";
				}
				$query="INSERT INTO posts SET USERID='".mysql_real_escape_string($USERID)."', title='".mysql_real_escape_string($qtitle)."',question='".mysql_real_escape_string($question)."', tags='".mysql_real_escape_string($qtitle)."', category='".mysql_real_escape_string($category)."', time_added='".time()."', date_added='".date("Y-m-d")."' $addtosql";
				$result=$conn->execute($query);
				$userid = mysql_insert_id();
				$message = $lang['5'];
			}
		}
	}
    }	

    else
    {
	$question = htmlentities(strip_tags($_REQUEST['qtitle']), ENT_COMPAT, "UTF-8");
	$redirect = base64_encode($thebaseurl."/ask?qtitle=".$question);
	header("Location:$config[baseurl]/login?redirect=$redirect");exit;
    }

I am trying the following code but this code replaces every word (which is not included in the array)

    FUNCTION BadWordFilter(&$text, $replace){

    $bads = ARRAY (
      ARRAY("butt","b***"),
      ARRAY("poop","p***"),
      ARRAY("crap","c***")
    );

      IF($replace==1) {                                        //we are replacing
      $remember = $text;

      FOR($i=0;$i<sizeof($bads);$i++) {               //go through each bad word
           $text = EREGI_REPLACE($bads[$i][0],$bads[$i][1],$text); //replace it
      }

      IF($remember!=$text) RETURN 1;                     //if there are any changes, return 1

     } ELSE {                                                  //we are just checking

      FOR($i=0;$i<sizeof($bads);$i++) {               //go through each bad word
           IF(EREGI($bads[$i][0],$text)) RETURN 1; //if we find any, return 1
      }     
     }
    }
    $qtitle = BadWordFilter($wordsToFilter,0); 
    $qtitle = BadWordFilter($wordsToFilter,1); 

What I am missing here?