filter bad words,list recent 10

This is a discussion on filter bad words,list recent 10 within the PHP Language forums, part of the PHP Programming Forums category; Okay, my snippet goes hand in hand it is supposed to not show bad words that were searched for and ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-01-2007
joanna
 
Posts: n/a
Default filter bad words,list recent 10

Okay, my snippet goes hand in hand it is supposed to not show bad
words that were searched for and it is supposed to show the 10 most
recent searches. Here's my problem, it is only showing the 10th row as
far as recent searches and the filtering of bad words doesn't work.

$query=@mysql_query("SELECT search,recent FROM search
ORDER BY recent ASC LIMIT 0,10 ");

while($row = mysql_fetch_array( $query ))
{

$badWords = array('stupid', 'Jerk');
$numBadWords = count($badWords);

for($i="0";$i<$numBadWords;$i++){
if(stripos($ss_mess,$badWords[$i]) != FALSE){

}
}

$recent=($row['search']);
}

echo $recent;

I should note that search is both a field and the name of the table (i
know not the best design) and the field "recent" is timestamp type.

Reply With Quote
  #2 (permalink)  
Old 11-01-2007
Captain Paralytic
 
Posts: n/a
Default Re: filter bad words,list recent 10

On 1 Nov, 10:32, joanna <m...@barrelofcrafts.com> wrote:
> Okay, my snippet goes hand in hand it is supposed to not show bad
> words that were searched for and it is supposed to show the 10 most
> recent searches. Here's my problem, it is only showing the 10th row as
> far as recent searches and the filtering of bad words doesn't work.
>
> $query=@mysql_query("SELECT search,recent FROM search
> ORDER BY recent ASC LIMIT 0,10 ");
>
> while($row = mysql_fetch_array( $query ))
> {
>
> $badWords = array('stupid', 'Jerk');
> $numBadWords = count($badWords);
>
> for($i="0";$i<$numBadWords;$i++){
> if(stripos($ss_mess,$badWords[$i]) != FALSE){
>
> }
>
> }
>
> $recent=($row['search']);
>
> }
>
> echo $recent;
>
> I should note that search is both a field and the name of the table (i
> know not the best design) and the field "recent" is timestamp type.


Your snippet uses a variable called $ss_mess which never seems to be
set. But then the if statement containing it has no code to do
anything either.

So all in all, I wouldn't expect this to do anything.

Reply With Quote
  #3 (permalink)  
Old 11-01-2007
C. (http://symcbean.blogspot.com/)
 
Posts: n/a
Default Re: filter bad words,list recent 10

On 1 Nov, 10:32, joanna <m...@barrelofcrafts.com> wrote:
> Okay, my snippet goes hand in hand it is supposed to not show bad
> words that were searched for and it is supposed to show the 10 most
> recent searches. Here's my problem, it is only showing the 10th row as
> far as recent searches and the filtering of bad words doesn't work.
>
> $query=@mysql_query("SELECT search,recent FROM search
> ORDER BY recent ASC LIMIT 0,10 ");
>
> while($row = mysql_fetch_array( $query ))
> {
>
> $badWords = array('stupid', 'Jerk');
> $numBadWords = count($badWords);
>
> for($i="0";$i<$numBadWords;$i++){
> if(stripos($ss_mess,$badWords[$i]) != FALSE){
>
> }
>
> }
>
> $recent=($row['search']);
>
> }
>
> echo $recent;
>
> I should note that search is both a field and the name of the table (i
> know not the best design) and the field "recent" is timestamp type.


You're doing it wrong - trying to exclude a dataset in PHP from a
dataset held in the database by moving them both to PHP. Try with them
both in the database:

SELECT search,recent FROM search OUTER JOIN badwords ON
(search.search=badwords.word)
WHERE badwords.word IS NULL
ORDER BY recent ASC LIMIT 0,10

C.

Reply With Quote
  #4 (permalink)  
Old 11-01-2007
joanna
 
Posts: n/a
Default Re: filter bad words,list recent 10

On Nov 1, 12:18 pm, "C. (http://symcbean.blogspot.com/)"
<colin.mckin...@gmail.com> wrote:
> On 1 Nov, 10:32, joanna <m...@barrelofcrafts.com> wrote:
>
>
>
> > Okay, my snippet goes hand in hand it is supposed to not show bad
> > words that were searched for and it is supposed to show the 10 most
> > recent searches. Here's my problem, it is only showing the 10th row as
> > far as recent searches and the filtering of bad words doesn't work.

>
> > $query=@mysql_query("SELECT search,recent FROM search
> > ORDER BY recent ASC LIMIT 0,10 ");

>
> > while($row = mysql_fetch_array( $query ))
> > {

>
> > $badWords = array('stupid', 'Jerk');
> > $numBadWords = count($badWords);

>
> > for($i="0";$i<$numBadWords;$i++){
> > if(stripos($ss_mess,$badWords[$i]) != FALSE){

>
> > }

>
> > }

>
> > $recent=($row['search']);

>
> > }

>
> > echo $recent;

>
> > I should note that search is both a field and the name of the table (i
> > know not the best design) and the field "recent" is timestamp type.

>
> You're doing it wrong - trying to exclude a dataset in PHP from a
> dataset held in the database by moving them both to PHP. Try with them
> both in the database:
>
> SELECT search,recent FROM search OUTER JOIN badwords ON
> (search.search=badwords.word)
> WHERE badwords.word IS NULL
> ORDER BY recent ASC LIMIT 0,10
>
> C.


Thanks for the replies, I got that piece of code from somewhere, and
honestly didn't notice that undefined string. I think I will move the
bad words out of the array and into a field. Thanks again.

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 07:40 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0