|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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:
I call this function like this ReplaceStr(rs("message"))
__________________
regards, Fulton |
|
#2
|
|||
|
|||
|
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 />")
....
|
|
#3
|
|||
|
|||
|
when i do the following:
PHP Code:
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. |
|
#4
|
|||
|
|||
|
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
|
|
#5
|
|||
|
|||
|
it works, thanks very much for your help
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > ASP Development > ASP badword filter help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|