6 Replies Latest reply on Sep 12, 2006 9:13 PM by azadisaryev

    URL type error

      Given the link


      and the second line in eventFile.cfm is

      <cfparam name="URL.eventID" default="0" type="integer" />.

      I get an error, "Diagnostics=Invalid parameter type. The value specified, "1000075371&getprogram=yes", must be a valid Integer. "

      what can i do? I thought about removing the 'type = "integer"'.

      Any insight would be most helpful.
      Thank you!
        • 1. Re: URL type error
          <newbie /> Level 1

          Have you considered using a different type in your cfparam tag?


          Good luck!
          • 2. URL type error
            jdeline Level 1
            I don't believe "numeric" is a valid type in CFPARAM.

            I reread your posting after I first responded (novel concept) and it seems that ColdFusion gobbled up the integer and everything to tright of it in the URL. Strange. It seems to have missed the "&" at the end of the integer. Maybe you have some non-printing characters, like ASCII 10 or 13 in the URL and don't know it.
            • 3. Re: URL type error
              azadisaryev Level 1
              your cfparam should validate it fine. i tested it and it works.
              the problem is, your url is url-encoded. the '&' sign in it is actually '%26' and coldfusion does not see a variable separator and treats your whole query string as one variable/name pair instead of two.
              why your url got url-encoded and how to work around it is another question...
              • 4. Re: URL type error
                Brian999 Level 1
                I'm sure you've hit the nail on the head.

                I think it has to do with the CFCONTENT tag. So how do I stop the URL from becoming encoded? Or test to see if it is encoded and then decode?

                • 5. Re: URL type error
                  <newbie /> Level 1

                  > I don't believe "numeric" is a valid type in CFPARAM.

                  You are correct.

                  Numeric is not listed in the CFMX 7 docs as a valid type for the cfparam tag.

                  However, it is listed as a valid type for CF ver 6.1 and ver 5.0

                  It seems to me that the cfparam tag should behave differently when using
                  the two different types (numeric vs integer).

                  For example what if the number to be passed is a really large number...


                  Or any number larger than 2147483647 for that matter.

                  Good luck!
                  • 6. Re: URL type error
                    azadisaryev Level 1
                    i believe you can't 'decode' a url and still use it as a structure and
                    retrieve individual keys from it...

                    i guess what you will have to do is:
                    1) decode the cgi.query_string variable
                    2) create a new structure
                    3) populate it with elements of the decoded cgi.query_string
                    4) use your cfparam validation on the new structure

                    here is a sample code that has worked for me. comments in code:

                    <!--- decode the cgi.query_string and assign its new value to a tmp
                    <cfset tmp = #urldecode(cgi.QUERY_STRING)#>
                    <!--- create new empty structure --->
                    <cfset tmp2 = structnew()>
                    <!--- loop through the tmp var as a list with '&' as delimiters,
                    storing each key/value pair in a listEl item
                    (your listEl itimes will now consist of all xxx=yyy pairs from your
                    cgi.query_string --->
                    <cfloop index="listEl" list="#tmp#" delimiters="&">
                    <!--- for each listEl item created by cfloop, create a key and value
                    and insert them as key and value into the tmp2 structure created before
                    <cfset tmp2_key = listgetat(listEl, 1, "=")><!--- create a key var and
                    assign it the xxx value from the listEl --->
                    <cfset tmp2_val = listgetat(listEl, 2, "=")><!--- create a val var and
                    assign it the yyy value from the listEl --->
                    StructInsert(tmp2, tmp2_key, tmp2_val, "true");<!--- this cfscript
                    populates our tmp2 structure with all key/value pairs --->
                    <!--- debug & test : remove this from production version --->
                    <cfdump var="#tmp2#"><!--- dump the new tmp2 structure --->
                    <!--- below i am using a isValid cf function to test that eventID is an
                    integer. you will use your cfparam. isvalid just allows me to assign
                    an output to evaluation that i can see --->
                    <cfif isvalid("integer", tmp2.eventID)>