CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   ColdFusion (http://www.codingforums.com/forumdisplay.php?f=45)
-   -   URL encodedFormat (http://www.codingforums.com/showthread.php?t=248477)

korssane 01-10-2012 11:47 PM

URL encodedFormat
 
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


Code:

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



destination page


Code:

<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 03:33 AM

Quote:

Originally Posted by korssane (Post 1179541)
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


Code:

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



destination page


Code:

<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 01: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 07: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


All times are GMT +1. The time now is 03:47 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.