• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

replace quotes?

Explorer ,
Nov 26, 2014 Nov 26, 2014

Copy link to clipboard

Copied

Hello I'm on Coldfusion 10 and I'm trying to figure out how to replace quotes ("). So far I tried this:

<cfset Session.Artist1 = Replace(Session.Artist1,"&quot;","&quot;",'ALL') >

That does nothing, I then tried this:

<cfset Session.Artist1 = Replace(Session.Artist1,"&#34","&quot;",'ALL') >

That errors out CF. I'll get this:

Error Occurred While Processing Request

Invalid construct: Either argument or name is missing.

So is there anything that would work in CF and in SQL for " (quotes)? I having people use the HTML &quot;, but that also shows up in SQL as the coding. I would like it to work in CF and in SQL as just ", but can't figure out how. Any help would be great.

Thanks

Views

1.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 26, 2014 Nov 26, 2014

Copy link to clipboard

Copied

Chr(34) is neat for the double quote. So try

<cfset Session.Artist1 = Replace(Session.Artist1, chr(34), "&quot;", "all") >

You could also be creative with single quotes, like this

<cfset Session.Artist1 = Replace(Session.Artist1, '"', '&quot;', 'all') >

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 26, 2014 Nov 26, 2014

Copy link to clipboard

Copied

I tried this and it doesn't do anything:

<cfset Session.Artist1 = Replace(Session.Artist1 , Chr(34),"&quot;",'ALL') >

What is happening is you can search for 'the "thing"' after you hit return CF will change it to 'the'. So it will ignore any characters after the ".

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 27, 2014 Nov 27, 2014

Copy link to clipboard

Copied

LATEST

I get no such complication. When I run the code

<cfset str='the "thing"'>

<cfset newStr = replace(str, chr(34),"&quot;","all")>

<cfoutput>#newStr#</cfoutput>

I get the result

the &quot;thing&quot;

Remember to view the result in the browser's source page.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation