November 6th, 2003, 05:05 PM
# and url String
I am building a url for a cfm page with a tool that gets info from a DB. The link appear in regular HTML. It populates a form that is on a cfm page. The data in the db address field sometimes contains # symbols e.g. 1000 Main Street #101. This make Cold Fusion Freak-Out (makes me freak-out as well) by passing this in as a url string. How can this be fixed? Need help today. Thanks.
This is the current code:
<cfif NOT IsDefined("url.a1")> <cfset #url.a1# = ""> </cfif>
<input type="text" name="address" size="40" <cfif#a1# NEQ "">value=<cfoutput>#a1#</cfoutput></cfif>>
November 7th, 2003, 12:21 PM
Try using the urlEncodedFormat() function when you output your query data into the URL string.
November 25th, 2003, 07:41 AM
This shouldnt matter
If ColdFusion is dealing with data that is alread in a variable, like data coming form a database, the ColdFusion will escape the chars automatically
so if you had myDomain.com/index.cfm?someVal=#hiThere, ColdFusion wont spit it cause its not having to deal with it directly. The only time ColdFusion will die is if you try something like this
If your doing stuff like that you have to escape the pounds like so
<cfset myVar = "Hello there. I am #1">
<cfset myVar = "Hello there. I am ##1">