Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

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")
Skilled Talker

Posts: 54
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".
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
.Fernando is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-18-2009, 12:22 PM Re: Delete Query with cronjobs+php (If its have "keyword")
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,516
Name: Chris Hirst
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!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?

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")
Skilled Talker

Posts: 54
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.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

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,226
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
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
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.56976 seconds with 12 queries