Jump to content

Easy Syntax fix for LIKE query with variable


Adam.A

Recommended Posts

Hi All,

 

I am trying to create a simple word filter for my database and I am having trouble with a little bit of syntax that passes the variable into the LIKE query.

 

I have had a good look through these forums and found this solution but I can’t get it to work with my code.(http://www.phpfreaks.com/forums/index.php/topic,241601.0.html)

 

I think I am really close and it’s just a issue with the quotation marks.

 

 

$badwords=array("ass","babbi","penis");
foreach ($badwords as $badword)
{      
//Delete query

$delete_sql = "DELETE FROM jos_facileforms_subrecords WHERE name LIKE \'%'.$badword.'%\' "; 


// execute $delete_sql  query and get result  

$filter_sql_result = mysql_query($delete_sql,$connection)  
	or die(mysql_error());   
echo $filter_sql_result; 
}      

 

any assistance would be greatly appreciated i have been searching for a solution for quite some time now.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.