Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ColdFusion / Advanced Techniques / May 2006



Tip: Looking for answers? Try searching our database.

cfqueryparam and trim causing ' to double to ''

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
sidelko - 17 May 2006 22:11 GMT
Has any one else seen this problem with CFMX (6,1,0,63958).

I have some queries running on a site with the version of CF listed above
where we had trim() statements around a form field which was then used as a
value for a cfqueryparam tag in an update query, and the ' were escaped to ''.  
There were even some cases of " going to \" and i think a few ' going to \'.

We developed this on a CFMX box (6,1,0,83762) where this didn't happen at all.

I even output the variable before and after the update, and the value had the
orginal number of quotes, but the param value from the query always had it
doubled.

This is the section of code i'm talking about.

communityShortDesc = <cfqueryparam cfsqltype="cf_sql_longvarchar"
value="#trim(attributes.communityShortDesc)#">,

That above statement would cause the ' to double, but just by taking out the
trim like below, the ' wouldn't double.

communityShortDesc = <cfqueryparam cfsqltype="cf_sql_longvarchar"
value="#attributes.communityShortDesc#">,

I think the only option I have is to go through and find all the trims in the
insert/update statements and remove then.  I'm just curious if anyone has any
other ideas for this.

Thanks,
Dan Bracuk - 17 May 2006 23:09 GMT
If the scope is attributes, it looks like a custom tag.  Trim the variable on the way in to the tag.
sidelko - 17 May 2006 23:29 GMT
The way our code base is set up, is that we dump all the form and url vars into
the attributes scope.   It isn't a custom tag but more of a fusebox type
methodolgy.  

we really don't need the trim, i'm not sure why the former developer put it
there.

but i could do a

<cfoutput>#attributes.var#</cfoutput>
<cfquery>
<cfoutput>#attributes.var#</cfoutput>

the two outputs show ' tick.  the param in cfquery when i look at the
debugging code has ''.

it is very odd indeed
sk8save - 29 May 2006 18:19 GMT
I have the exact same problem.

I was suggested the PreserveSingleQuotes function, which didn't work. Anyone know a fix?
Adam Cameron - 29 May 2006 20:37 GMT
> I was suggested the PreserveSingleQuotes function, which didn't work. Anyone know a fix?

One thing that's not immediately obvious with preserveSingleQuotes(), is
that it ONLY works within <cfquery> tags.  It achieves nothing if you do it
outwith those tags.  I'm not sure whether this is relevant to your
situation.

Signature

Adam

Fernis - 29 May 2006 22:27 GMT
Ahem. Let me picture this.

It did work right in the updated CFMX 6.1.

It did not work in the older CFMX 6.1.

"The cfqueryparam tag doubled single quotation marks (') when strings were
manipulated within the tag attributes." is the _FIRST_ issue that is mentioned
in the Macromedia's CFMX 6.1 updater fix-list.

...sometimes it's just so, So very difficult to remain calm and polite,
when....  awww forget it. *rolleyes*

;-)
sidelko - 31 May 2006 22:47 GMT
LOL, i guess I should have checked that.

<a target=_blank class=ftalternatingbarlinklarge
href="http://www.adobe.com/support/documentation/en/coldfusion/mx61updater/relea
senotes_cfmx61_updater02.html


I">http://www.adobe.com/support/documentation/en/coldfusion/mx61updater/releasen
otes_cfmx61_updater02.html

I</a> agree, the *rolleyes* is approiate here.  But iguess that is what I get
for assuming that both servers were up to date.

Sean
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.