...

View Full Version : URL encodedFormat



korssane
01-11-2012, 12:47 AM
Hi Peers,

i'am trying to pass a URL "encodedFormat" string to another page.
I'am having trouble to pass symbols like # otherwise everything else seem to work.

source page



<cfset var1="abc$d">
<cflocation url="URLDECODE.cfm?var11=#urlEncodedFormat(var1)#">



destination page



<cfoutput>
The url variable passed is : #URL.var11# </cfoutput>


if i put var1="abc12#", this will gimme an error ...

problem happens with "#" symbol ...


Thoughts

teedoff
01-13-2012, 04:33 AM
Hi Peers,

i'am trying to pass a URL "encodedFormat" string to another page.
I'am having trouble to pass symbols like # otherwise everything else seem to work.

source page



<cfset var1="abc$d">
<cflocation url="URLDECODE.cfm?var11=#urlEncodedFormat(var1)#">



destination page



<cfoutput>
The url variable passed is : #URL.var11# </cfoutput>


if i put var1="abc12#", this will gimme an error ...

problem happens with "#" symbol ...


Thoughts

Since the # symbol is a special character in coldfusion, you need to escape it in a string. Try "abc12##" instead.

korssane
01-13-2012, 02:23 PM
hi teedoff,

Thanks, but how if i'am passing a text field value and the user has entered a # sign in the text field ??..how can i double the # sign then..

thanks.

Gjslick
01-14-2012, 08:33 AM
You shouldn't need to. This is only an issue when you are typing string literals with the '#' symbol into ColdFusion code. Putting in a <cfset something = "hi##"> will produce the literal string "hi#", which is then set to the variable something. In this case, the double hash symbol (##) in ColdFusion code escapes into a single hash symbol (#).

However, whatever someone types into a textfield will not be parsed and processed by ColdFusion. They could type this into a textfield: "oogly #boogly#", and they will get the literal string "oogly #boogly#". However, if you put that in CF code as the value for say, a <cfset> (such as with <cfset something = "oogly #boogly#">), then you would get an error message: "variable 'boogly' is not defined".

-Greg



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum