How do I get CF Server to ignore the double quotes within strings and variables.

my problem is simple I have a comapany name that contains ""in it how do I get the server to ignore those.

right now it is cutting the name out at the first instance of ".


cfset company = "my job "athome"">

at the output it only displays

MY job.....

its probly real simple
Who is Participating?
Hi there,

The bost possible solution would be - replacing all ur doubel quotes ["] with 2 single quotes ['']

since they appear same in display - it works fine.

try it & let me know.

You can escape the "'s.
<cfset company = "my job ""athome""">

or use single quotes like this

<cfset company='my job "athome"'>

This would work also
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

jriver12Author Commented:
so if I was passing the company variable thru the url from a form, would I pass it like

jriver12Author Commented:
I think I need to rephrase.

I am not setting a variable that contains something"something"Somethingelse

the user elects to use "" within letsay the company name.

how do I get cf to  escape the doublequotes so the entire content of the variableshows
If its in the database as lets say:


then CF should output it just the same.
<cfquery name="myQuery" dataasource="whatever">
sleect companyName
from companies

<cfoutput query="myQuery">

This should be no problem.  The only time you should have problems with single or double quotes is when you do an insert or update.

Are you displaying a the company name just from a posted form or from an SQL query?

Can you post all of your code?
Hi again,
I understand that u r not setting a variable.

but when u try & display this data containing double quotes [as inserted in DB] - it gives u a problem right.

so wehn u display this data use -


u can use this to display ur data - without ne-erros & it will be printed as if its double quotes - though its acutally 2 single quotes.


u could also have another way to work around this ...

ie in ur application.cfm file - set a variblae called
<cfset doublequote = '"'>

Now every time u insert data in ur data base use


what this would do - is insert data in ur table as - lets say
anand#doublequotes#s [instead of anand"s]

but when u display this variable as it is on ne-page.

this value would be displayed as anand"s - as #doublequotes# is initialised in UR application file.

Hope this helps out
else let me know

jriver12Author Commented:
This is getting even weirder.

when I output my data containing "" in the variable like
Mr.Ts "house"

when I output it like this
it displays Mr.Ts "house" thats great.

now when I display the same variable in this manner
<cfoutput><input type="text" name="textline" value='#mrtsvariable#'>

it displays like this in the field:
hence cutting off the "house" part.

any suggestions.....
Hi there,

I told u replace ur Double quote with 2 single quotes & then display ur value in textbox as
ie ur variable becomes - Mr.Ts ''house''

<input type="text" name="textline" value="#mrtsvariable#">

there u go - it gets displayed competely without getting cut.


abt ur q's it b'cos - when displaying there r no quotes surrounding the variable - but when u display it in a text box - u have it enclosed in the quotes of the value attribute of the input box.

hope that makes things clear ....


Hi, there.

How you deal with a variable that may contain quotes depends on where you're using it, and Cold Fusion has functions specifically designed to do what you need.  If you are putting the variable in the query string of a url, use the URLEncodedFormat function:


If you want to display the value in an input form field, use the HTMLEditFormat function, which will also guard against someone using html code:

<input type="text" name="textline" value="#HTMLEditFormat(mrtsvariable)#">

Hi David,

I have tried using HTMLEditFormat - but this dosent help in escaping the single & double quotes present within the string.

thats why i came up with the replace function ...


jriver12Author Commented:
thanks yall. :^)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.