Solved

Invalid CFML Error when using Replace Function

Posted on 2011-09-30
2
267 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

786 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