<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>FanaticZine &#187; CFQUERY</title>
	<atom:link href="http://www.fanaticzine.com/index.php/tag/cfquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.fanaticzine.com</link>
	<description>Creativity Simplified</description>
	<lastBuildDate>Wed, 09 Mar 2011 05:52:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>ColdFusion CFQUERY character escape issue solved</title>
		<link>http://www.fanaticzine.com/index.php/2008/12/coldfusion-cfquery-character-escape-issue-solved/</link>
		<comments>http://www.fanaticzine.com/index.php/2008/12/coldfusion-cfquery-character-escape-issue-solved/#comments</comments>
		<pubDate>Fri, 26 Dec 2008 10:35:47 +0000</pubDate>
		<dc:creator>z7oofy</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[' to "]]></category>
		<category><![CDATA[CFQUERY]]></category>
		<category><![CDATA[Character Escape problem]]></category>
		<category><![CDATA[single-quote to double-quote problem]]></category>

		<guid isPermaLink="false">http://www.fanaticzine.com/?p=66</guid>
		<description><![CDATA[Today I was trying this ColdFusion Code, which derived me crazy for about hour, finally I found the solution for the problem. I&#8217;ll post this code, so if anybody go through the same, to make it little easy on them. ok here I go.. in my script I used a SQL query looks something like [...]]]></description>
			<content:encoded><![CDATA[<p>Today I was trying this ColdFusion Code, which derived me crazy for about hour, finally I found the solution for the problem. I&#8217;ll post this code, so if anybody go through the same, to make it little easy on them. ok here I go..</p>
<p>in my script I used a  SQL query looks something like this,</p>
<p><span style="color: #800000;">&lt;cfset</span> strSQL=<span style="color: #339966;">&#8220;</span><span style="color: #339966;">SELECT * FROM TestTable WHERE test_id=</span><span style="color: #99cc00;"><span style="color: #339966;">&#8216;xx&#8217;&#8221;</span><span style="color: #800000;">&gt;</span></span></p>
<p><span style="color: #800000;">&lt;cfquery</span> <span style="color: #800000;">datasource=</span><span style="color: #0000ff;">&#8220;xxxxxx&#8221; </span> <span style="color: #800000;">name=</span><span style="color: #0000ff;">&#8220;xxxxxxx&#8221;</span> <span style="color: #800000;">result=</span><span style="color: #0000ff;">&#8220;xxxxx&#8221;</span><span style="color: #800000;"> &gt;</span><br />
#strSQL#<br />
<span style="color: #800000;">&lt;/cfquery&gt;</span></p>
<p>If you try something like that, it should should pop you a SQL error, if you look the query closely, you would notice that the CFQUERY executes the following command, which we passed in to it.</p>
<p>SELECT * FROM TestTable WHERE test_id=<span style="color: #ff0000;">&#8220;xx&#8221;</span></p>
<p>you should see that there is a differance between command which get executed and with the one passed in. Means it converts &#8221; <span style="color: #ff0000;">&#8216;</span> &#8221; character in to &#8221; <span style="color: #ff0000;">&#8220;</span> &#8221; this would pop a sql error,</p>
<p>The Reason for this is, CF has it&#8217;s automated character escape feature, if you send the above code, CF <span style="color: #ff0000;">DOES NOT ESCAPE </span>those characters, But CF Escape any character which are queted with single-quotes,</p>
<p>so the simple solution for the problem is to tell the CF to escape the special characters which are in the command, so this is how we doing to do it.</p>
<p><span style="color: #800000;">&lt;cfset</span> strSQL=<span style="color: #339966;">&#8220;</span><span style="color: #339966;">SELECT * FROM TestTable WHERE test_id=</span><span style="color: #99cc00;"><span style="color: #339966;">&#8216;xx&#8217;&#8221;</span><span style="color: #800000;">&gt;</span></span></p>
<p><span style="color: #800000;">&lt;cfquery</span> <span style="color: #800000;">datasource=</span><span style="color: #0000ff;">&#8220;xxxxxx&#8221; </span> <span style="color: #800000;">name=</span><span style="color: #0000ff;">&#8220;xxxxxxx&#8221;</span> <span style="color: #800000;">result=</span><span style="color: #0000ff;">&#8220;xxxxx&#8221;</span><span style="color: #800000;"> &gt;</span><br />
# <span style="color: #ff0000;">&#8216;#strSQL#&#8217;</span> #<br />
<span style="color: #800000;">&lt;/cfquery&gt;</span></p>
<p>Problem solved, your query should work now.. <img src='http://www.fanaticzine.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.fanaticzine.com/index.php/2008/12/coldfusion-cfquery-character-escape-issue-solved/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

