Adam.A Posted March 12, 2009 Share Posted March 12, 2009 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. Link to comment https://forums.phpfreaks.com/topic/149060-easy-syntax-fix-for-like-query-with-variable/ Share on other sites More sharing options...
Philip Posted March 12, 2009 Share Posted March 12, 2009 Look at it with syntax highlighting: $delete_sql = "DELETE FROM jos_facileforms_subrecords WHERE name LIKE \'%'.$badword.'%\' "; $delete_sql = "DELETE FROM jos_facileforms_subrecords WHERE name LIKE '%".$badword."%' "; Link to comment https://forums.phpfreaks.com/topic/149060-easy-syntax-fix-for-like-query-with-variable/#findComment-782719 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.