Reply
Delete Query with cronjobs+php (If its have "keyword")
Old 10-18-2009, 12:14 PM Delete Query with cronjobs+php (If its have "keyword")
Experienced Talker

Posts: 30
Trades: 0
Hello, I have a website that's create a search history, but some users search for "pr0n" and i don't want that the search history show it in the homepage.

I know how to do it for a single keyword, example:
PHP Code:
<?
require_once("includes/config.php");

// Delete Bobby from the "example" MySQL table
mysql_query("DELETE FROM history WHERE query='sex"
or die(
mysql_error());  
?>
But it will just delete the query "sex" and don't "sex-tape", "sex-anything" or "sex-example".

What I want do is create a badwords list and ANY query if include this words in the query will be deleted via cronjobs.

"Fast" don't will delete just the query "Fast" but the queries "Fast", "Fast-job" or "Fast-anything".
.Fernando is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 10-18-2009, 12:22 PM Re: Delete Query with cronjobs+php (If its have "keyword")
chrishirst's Avatar
Super Moderator

Posts: 22,271
Location: Blackpool. UK
Trades: 0
Use wildcards and a LIKE criteria

WHERE query LIKE '%sex%'

but be aware that it will match such things as

"Sussex", "sextuplet" & "expertsexchange.com"
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Growing old is mandatory - Growing up is optional
Code Samples | People Counting System | Bits & Bobs

Last edited by chrishirst; 10-18-2009 at 12:25 PM..
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-18-2009, 12:45 PM Re: Delete Query with cronjobs+php (If its have "keyword")
Experienced Talker

Posts: 30
Trades: 0
Quote:
Originally Posted by chrishirst View Post
Use wildcards and a LIKE criteria

WHERE query LIKE '%sex%'

but be aware that it will match such things as

"Sussex", "sextuplet" & "expertsexchange.com"
It's Working.

Last edited by .Fernando; 10-18-2009 at 12:50 PM..
.Fernando is offline
Reply With Quote
View Public Profile
 
Old 10-21-2009, 12:26 PM Re: Delete Query with cronjobs+php (If its have "keyword")
mtishetsky's Avatar
King Spam Talker

Posts: 1,166
Name: Mike
Location: Mataro, Spain
Trades: 0
You may use regexp instead of like, it will give you more flexibility (traded for speed)

[[:<:]], [[:>:]]

These markers stand for word boundaries. They match the beginning and end of words, respectively. A word is a sequence of word characters that is not preceded by or followed by word characters. A word character is an alphanumeric character in the alnum class or an underscore (_).

mysql> SELECT 'a word a' REGEXP '[[:<:]]word[[:>:]]'; -> 1
mysql> SELECT 'a xword a' REGEXP '[[:<:]]word[[:>:]]'; -> 0
__________________
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Reply     « Reply to Delete Query with cronjobs+php (If its have "keyword")
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 



Page generated in 0.12639 seconds with 13 queries