sql string querying with wildcard

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

toonarific

Thread Starter
Joined
Aug 17, 2004
Messages
18
I currently have a php file that runs when users submit text in certain fields around my site. Right now, the file only looks for specifics words I enter into a table, and it only finds exact words. What I want to do is have the sql tring be able to use wildcard values around the {invalid_word} tag so it can find and prevent a user from submitting text if a long word contains the text on my banned list. Like, if I banned the word hair, and someone tried using the word hairball, it would let them. This is what the current php file code is


Code:
Code:
<?php
	# **** FIND BAD WORDS INTO THE ENTERED STRING **** #
	# @param $str - takes an argument as an string
	# match with database keywords
	# return true if bad word found
	# return false if bad word not found
	
	function findBadWords( $str ){
		
		$return = false;
		
		if( strlen( $str ) > 0 ) {
			$sql 		= "SELECT * FROM tbl_invalidunm WHERE MATCH (invalid_word) AGAINST (LCASE('".$str."') IN BOOLEAN MODE)";
			$rs 		= mysql_query( $sql ) or die( "Invalid query - ". mysql_error() );
			
			if($rs){
				$row_count 	= mysql_num_rows($rs);
				
				if( $row_count > 0 ) {
					$return = true;
				}
			} // if
		} // if
		return $return;
		
	} // end function 

?>
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Top