Go Back   CodingForums.com > :: Server side development > Other server side languages/ issues > ColdFusion

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-10-2012, 11:47 PM   PM User | #1
korssane
Regular Coder

 
Join Date: Jun 2011
Posts: 148
Thanks: 18
Thanked 0 Times in 0 Posts
korssane is an unknown quantity at this point
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
korssane is offline   Reply With Quote
Old 01-13-2012, 03:33 AM   PM User | #2
teedoff
Senior Coder

 
Join Date: Aug 2010
Location: High Point, NC
Posts: 3,325
Thanks: 5
Thanked 363 Times in 360 Posts
teedoff is on a distinguished road
Quote:
Originally Posted by korssane View Post
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.
__________________
Teed
teedoff is offline   Reply With Quote
Old 01-13-2012, 01:23 PM   PM User | #3
korssane
Regular Coder

 
Join Date: Jun 2011
Posts: 148
Thanks: 18
Thanked 0 Times in 0 Posts
korssane is an unknown quantity at this point
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.
korssane is offline   Reply With Quote
Old 01-14-2012, 07:33 AM   PM User | #4
Gjslick
Regular Coder

 
Join Date: Feb 2009
Location: NJ, USA
Posts: 476
Thanks: 2
Thanked 70 Times in 69 Posts
Gjslick will become famous soon enough
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
Gjslick is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:05 PM.


Advertisement
Log in to turn off these ads.