ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 14th, 2003, 11:26 PM
DDDooGGG DDDooGGG is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Melbourne, Australia
Posts: 97 DDDooGGG User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 m 33 sec
Reputation Power: 7
Question ASP badword filter help

Hi i am trying to add a bad word filter to my forum. I have the following function, but it doesnt seem to work, what am i doing wrong?
PHP Code:
 strForumConn "Provider=Microsoft.jet.OLEDB.4.0; Data Source=" Server.MapPath("forum.mdb")
set connForum Server.CreateObject("ADODB.Connection")
connForum.Open strForumConn
strSQL 
"SELECT badword, badwordreplace from badwords"
Set RS1 connForum.Execute(strSQL)

    
Dim myArray()
    
numRows 0
Function ReplaceStr(str
    Do While 
NOT RS1.EOF
        numRows 
numRows 1
        ReDim Preserve myArray
(2numRows)
        
myArray(0numRows 1) = RS1(0)
        
myArray(1numRows 1) = RS1(1)
        
        
replace strRS1(1) , RS1(0))
        
        
RS1.MoveNext
    Loop
    ReplaceStr 
str 
End 
Function 


I call this function like this ReplaceStr(rs("message"))
__________________
regards,


Fulton

Reply With Quote
  #2  
Old January 15th, 2003, 02:15 PM
numbernine numbernine is offline
Up To His Eyes In Ads
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Chicago
Posts: 160 numbernine User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 25 sec
Reputation Power: 7
Is it giving you an error? Or just returning the string without replacing any bad words?

It might be because you are opening the recordset outside of the function. So after the first call to ReplaceStr(), the recordset is sitting at .EOF for all subsequent calls; and if the recordset is at .EOF it won't go through any of the logic in your "Do While Not .EOF" block.

You can check this by adding something like and seeing if the text shows up in your page.

Code:
Function ReplaceStr(str) 
  Do While NOT RS1.EOF
     Response.Write("Replacing bad words..." & <br />")
       ....

Reply With Quote
  #3  
Old January 15th, 2003, 06:44 PM
DDDooGGG DDDooGGG is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Melbourne, Australia
Posts: 97 DDDooGGG User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 m 33 sec
Reputation Power: 7
when i do the following:
PHP Code:
 str "Theses are the words to be replaced **** **** **** ****"
Do While NOT RS1.EOF
    numRows 
numRows 1
    ReDim Preserve myArray
(2numRows)
    
myArray(0numRows 1) = RS1(0)
    
myArray(1numRows 1) = RS1(1)
    
    
Response.Write("" replace(strRS1(0), RS1(1)) & "<br>")
    
RS1.MoveNext
Loop 

this is what is written to the html page:
Theses are the words to be replaced **** c**t **** c**t
Theses are the words to be replaced f**k **** **** ****
Theses are the words to be replaced **** **** s**t ****

it seems that it changes the first badword in the database ie "****" and then loops to the next response.write and replaces the second word in the database, thats why it is written 3 times and hasnt replaced 3 different words

hope you can help.
thanks,

Last edited by DDDooGGG : January 15th, 2003 at 06:48 PM.

Reply With Quote
  #4  
Old January 16th, 2003, 01:04 AM
numbernine numbernine is offline
Up To His Eyes In Ads
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Chicago
Posts: 160 numbernine User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 25 sec
Reputation Power: 7
Hey Fulton,
That's because you're not saving the replaced string. You're just printing it out. Try:

Code:
str = "Theses are the words to be replaced **** **** **** ****"
Do While NOT RS1.EOF
    numRows = numRows + 1
    ReDim Preserve myArray(2, numRows)
    myArray(0, numRows - 1) = RS1(0)
    myArray(1, numRows - 1) = RS1(1)
    
    str = replace(str, RS1(0), RS1(1)) 
    Response.Write(str & "<br>")
    RS1.MoveNext
Loop

Reply With Quote
  #5  
Old January 16th, 2003, 05:57 AM
DDDooGGG DDDooGGG is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Melbourne, Australia
Posts: 97 DDDooGGG User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 m 33 sec
Reputation Power: 7
it works, thanks very much for your help

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > ASP badword filter help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT