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,""",""",'ALL') >
That does nothing, I then tried this:
<cfset Session.Artist1 = Replace(Session.Artist1,""",""",'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 ", 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
Copy link to clipboard
Copied
Chr(34) is neat for the double quote. So try
<cfset Session.Artist1 = Replace(Session.Artist1, chr(34), """, "all") >
You could also be creative with single quotes, like this
<cfset Session.Artist1 = Replace(Session.Artist1, '"', '"', 'all') >
Copy link to clipboard
Copied
I tried this and it doesn't do anything:
<cfset Session.Artist1 = Replace(Session.Artist1 , Chr(34),""",'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 ".
Copy link to clipboard
Copied
I get no such complication. When I run the code
<cfset str='the "thing"'>
<cfset newStr = replace(str, chr(34),""","all")>
<cfoutput>#newStr#</cfoutput>
I get the result
the "thing"
Remember to view the result in the browser's source page.