Solved

Invalid CFML Error when using Replace Function

Posted on 2011-09-30
2
261 Views
Last Modified: 2012-05-12
Hi,

I am using the replace function to clean up some html content.  Some of the text is in quotes and I believe that is why I am getting the error.  Anyway around this?
Thanks in advance!

<cfcomponent>
   
    <cffunction name="createEditorFile1" access="remote" returnType="string">
      <cfargument name="data" type="string" required="true">
         <cfargument name="GroupNo" type="string" required="true">
          <cfargument name="NPSGroupNumber" type="string" required="true">
         <cfargument name="NPSGroupSection" type="string" required="true">
          <cfargument name="BPIDReg" type="string" required="true">

             <cfset cleanData = replace(#cleandata#,"<th class="col1" />","<th class="col1">&nbsp;</th>","all")>
               
      <cfreturn cleanData>
    </cffunction>
   
   
</cfcomponent>
       
0
Comment
Question by:armanbena
2 Comments
 
LVL 10

Expert Comment

by:stu215
ID: 36892658
0
 
LVL 39

Accepted Solution

by:
gdemaria earned 500 total points
ID: 36892713

You have nested quotes in your statement...  you cannot enclose quotes within quotes unless they are escaped or different types of quotes

   <cfset cleanData = replace(#cleandata#,"<th class="col1" />","<th class="col1">&nbsp;</th>","all")>

Enclose in single quotes instead (and of course get rid of the useless #s around cleanData)

   <cfset cleanData = replace(cleandata,'<th class="col1" />','<th class="col1">&nbsp;</th>',"all")>
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now