Ask a Question related to Coldfusion Database Access, Design and Development.
-
Gregd66 #1
cfquery not escaping single quotes correctly
It seems as if two single quotes together do not get escaped.
<!---
This code works in CF5 with the proper Data OK message.
It does not work on MX7 using an oracle jdbc or native driver.
If you look at the debug of the insert statement you will see it
is not escaped correctly. CF is suppossed to escape it automatically.
--->
<cfset dsn="testdsn">
<cfset mydata="'' '"> <!--- if you put a character between the first 2 single
quotes it will work in MX7 ???? --->
<cfquery name="selectdata" datasource="#dsn#">
truncate table temp_table
</cfquery>
<cfquery name="inserttest" datasource="#dsn#">
insert into temp_table
(testdata)
values
('#mydata#')
</cfquery>
<cfquery name="selectdata" datasource="#dsn#">
select testdata
from temp_table
</cfquery>
<cfoutput>
<cfif selectdata.testdata neq mydata>
ERROR: DB data #selectdata.testdata# does not match original #mydata#
<cfelse>
Data OK.
</cfif>
</cfoutput>
Gregd66 Guest
-
#40704 [NEW]: strip_tags does not handle single quotes correctly (another regression)
From: email at steffenweber dot net Operating system: Linux PHP version: 5.2.1 PHP Bug Type: Strings related Bug... -
#40637 [NEW]: strip_tags does not handle single quotes correctly (regression)
From: email at steffenweber dot net Operating system: Linux PHP version: 5.2.1 PHP Bug Type: Strings related Bug... -
Bug: Escaping of single-quotes in cfQuery !
Attached code for better layout: CF automatically escapes single-quotes when outputtting values in queries. (Reason: Preventing of... -
MS Access driver not escaping single quotes?
I was eventually able to 'solve' this problem by breaking my complicated page into several simpler ones. Even removing chunks of cf tags _after_... -
Escaping single quotes
"Bruce A. Black" <bruceablk@ida.net> wrote in message news:3f2603af_2@newsfeed... Use stripslashes() on your text field before submitting.... -
jonwrob #2
Re: cfquery not escaping single quotes correctly
Originally posted by: Gregd66
It seems as if two single quotes together do not get escaped.
<cfquery name="inserttest" datasource="#dsn#">
insert into temp_table
(testdata)
values
('#mydata#')
</cfquery>
Bad programming practice. Use:
<cfquery name="inserttest" datasource="#dsn#">
insert into temp_table
(testdata)
values
( <cfqueryparam cfsqltype="CF_SQL_LONGVARCHAR" value="#mydata#"> )
</cfquery>
Good programming practice. Also resolves your quotes issue.
JR
jonwrob Guest



Reply With Quote

