Solved

Invalid CFML Error when using Replace Function

Posted on 2011-09-30
2
269 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Suggested Solutions

PROBLEM:  How to open a cfwindow or run a function on double click of a cfgrid row. One of my clients wanted to be able to double click on a row item to get more detailed information about a transaction and to be able to modify the line items i…
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

752 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