Thanks John,

It seems to be working now. Incidentally, there wasn't a where clause yet, I
have added it now.

Many Thanks

Will

-----Original Message-----
From: John [mailto:[EMAIL PROTECTED]]
Sent: 18 May 2001 13:39
To: CF-Talk
Subject: RE: profanity checker


It looks to me like you are setting the variable newlist equal to the form
field after a replace.  The problem lies mostly that every time you loop
over this you reset the variable. So of the list result from the query has
no matches then your variable will be equal to the original form field. The
second problem I see is the variables you are passing the function. On a
final note you said the administrator could set the level. I don't see a
where clause in the query. However, try this.


<cfset newlist = #form.bodytext#>

<cfloop query="getprofanities">
        <cfset newlist = ReplaceNoCase("#newlist#", "#getprofanities.badword#",
        "#getprofanities.rate1#", "ALL")>
</cfloop>

-----Original Message-----
From: Will Swain [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 18, 2001 5:22 AM
To: CF-Talk
Subject: profanity checker


Hi all,

I posted this a few days ago, and was directed towards some custom tags, but
none of them seem to work exactly how I want them, and I would like to come
up with something myself.

I have a Access db table which contains a list of badwords, and 3 ratings
for each. The administrator sets the profanity rating, with 1 being the most
strict and 3 the least. Assuming it is set to 1, the badwords should be
replaced with corresponding number of *.

So, I run a query, selecting all the badwords and their corresponding
'cleaned up' versions. Then I need to loop over a form field, checking each
word in it to see if it matches a badword, and replacing it with it's
'cleaned up' version if it does.


<!--- Pull out all the bad words from the database --->

<cfquery name="getprofanities" datasource="#APPLICATION.chatdsn#">
        SELECT ID, badword, rate1
        FROM tbl_profanity
</cfquery>

<!--- Loop over the profanity list and compare with words in the
bodytext --->


<cfloop query="getprofanities">

        <cfset newlist = ReplaceNoCase(bodytext, "getprofanities.badword",
"getprofanities.rate1", "ALL")>

</cfloop>

This code doesn't seem to work, and to be honest I'm not surprised, but my
head seems to be somewhere else today and I just can't get it!!! Any help
anyone......please?? :)

TIA

Will
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to