2 Replies Latest reply on May 31, 2007 1:01 PM by koencidence

    Element is undefined in URL

    DARAB
      I can't seem to use a named field in a URL's querystring when it contains a hyphen. Here's my code:

      <body>
      item1 = <cfoutput>#url.item1#</cfoutput>
      orderID = <cfoutput>#url.orderID#</cfoutput>
      card_type = <cfoutput>#url.card-type#</cfoutput>
      </body>

      I have no problem with item1 or orderID but card-type returns the error message:

      " Element CARD is undefined in URL."

      This URL is coming from a third party so I can't change it.
        • 1. Re: Element is undefined in URL
          Level 7
          DARAB wrote:
          > I can't seem to use a named field in a URL's querystring when it contains a
          > hyphen. Here's my code:
          >
          > <body>
          > item1 = <cfoutput>#url.item1#</cfoutput>
          > orderID = <cfoutput>#url.orderID#</cfoutput>
          > card_type = <cfoutput>#url.card-type#</cfoutput>
          > </body>
          >
          > I have no problem with item1 or orderID but card-type returns the error
          > message:
          >
          > " Element CARD is undefined in URL."
          >
          > This URL is coming from a third party so I can't change it.
          >

          This seems to be the week of the "array notation".

          You can not use an invalid variable name string in a dot notation
          expression. What ColdFusion is trying to do is evaluate 'url.card'
          minus 'type' and can not find an 'url.card'.

          To use invalid variable string names one need to use array notation.
          url["card-type"] should get you what you want.

          • 2. Re:  Element is undefined in URL
            koencidence Level 1
            Have you tried dumping the URL scope to see if it's in there any other way?

            You could also use the cgi.query_string variable to parse it out if for some reason ColdFusion doesn't like it.

            Koen