EasyCFM.COM ColdFusion Forums / Coding Help! / URL variable mishap

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: URL variable mishap

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

gaverp
08-31-2010 @ 4:56 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 3
Joined: Apr 2009

Hello...
I'm trying to use the Google IPN process to capture transactions from google checkout and it requires that I catch the value of a variable named serial-number on the url they send to my action page.

When I try to code the page to set the variable it fails stating no variable exists in the URL by that name...

The code looks like this...
<CFSET sn= #URL.serial-number#>

The URL looks like this...
http://www.domain.com/googletest.cfm?serial-number=12345

The Error message looks like this...
Element SERIAL is undefined in URL

It appears CF is trying to interpret serial-number as a numeric value and subtract the value of number from serial? I tried #DE(URL.serial-number)# without success.

Any help would be greatly appreciated.

GP



cfSearchin
08-31-2010 @ 5:31 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 608
Joined: Feb 2008

For variable names that contain invalid characters, use associative array notation

<cfset result = URL["variable-name"]>
ie
<CFSET sn = URL["serial-number"]>

gaverp
08-31-2010 @ 6:43 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 3
Joined: Apr 2009

Thank you!

GP

dlackey
08-31-2010 @ 9:59 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 935
Joined: Jun 2007

Just to explain the error you are receiving, CF is reading #URL.serial-number# as an expression, not as a variable.  CF is expecting to subtract url.serial minus number to come up with a quotient.  

Or in code-speak:
<cfset url.serial = 4>
<cfset number = 2>
<cfoutput>#url.serial-number#</cfoutput>

So when you reference url.serial-number, to CF that variable doesn't exists unless you give CF more details which is what is being done with cfSearchin post.

HTH

Cheers,
Chip

cfSearchin
08-31-2010 @ 10:22 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 608
Joined: Feb 2008

Great explanation! Cheers

Sponsored By...
iOpenSoft, LLC is a Houston, Texas Advanced Technology Studio Specializing in Web Design, Web Development, iPhone App Development and Android App Development.