Don't you want to use preservesinglequotes()?

CFQUERY automatically assumes they are escaped when it saves, and
preservesinglequotes() will escape all your single ticks for you.

Basically you could achieve the same result by making the string be 

<cfset Var = "<cfset value = ''''>">

In the first place.

Just be careful of what input you allow to me ran through the
preservesinglequotes function inside of a CFQUERY, because that opens
the door for SQL injection holes if you are inserting data from a url or
form submit.

New Code:

<cfset Var = "<cfset value = ''>">

<cfquery name="Store_Var" datasource="Test">
   UPDATE Table
   SET Field = '#preservesinglequotes(Var)#'
</cfquery>

Hope this helps.

~Brad


-----Original Message-----
From: David Delbridge [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 01, 2006 7:01 PM
To: CF-Talk
Subject: Disappearing Single-Quote

Hi all,

How do I keep CF from interpreting two single-quotes as escaped?  I'm
storing code snippets into a database and all occurences of "''" are
becoming "'" (e.g., "<cfset value = ''>" becomes "<cfset value = '>").

For example:

<cfset Var = "<cfset value = ''>">

<cfquery name="Store_Var" datasource="Test">
   UPDATE Table
   SET Field = '#Var#'
</cfquery>

When queried, the value of Field in Table is "<cfset value = '>"

Any advice is appreciated.



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:242039
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to