• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

URL type error

New Here ,
Sep 11, 2006 Sep 11, 2006

Copy link to clipboard

Copied

Given the link

https://www.site/eventFile.cfm?eventID=1000075371&getprogram=yes

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!
TOPICS
Advanced techniques

Views

477

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 11, 2006 Sep 11, 2006

Copy link to clipboard

Copied


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

From...
type="integer"
to
type="numeric"


Good luck!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 11, 2006 Sep 11, 2006

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Sep 12, 2006 Sep 12, 2006

Copy link to clipboard

Copied

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...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 12, 2006 Sep 12, 2006

Copy link to clipboard

Copied

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?

Thanks!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 12, 2006 Sep 12, 2006

Copy link to clipboard

Copied


> 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...

eventID=10000753719876


Or any number larger than 2147483647 for that matter.

Good luck!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Sep 12, 2006 Sep 12, 2006

Copy link to clipboard

Copied

LATEST
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
var--->
<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="&">
<cfoutput>
<!--- 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 --->
<cfscript>
StructInsert(tmp2, tmp2_key, tmp2_val, "true");<!--- this cfscript
populates our tmp2 structure with all key/value pairs --->
</cfscript>
</cfoutput>
</cfloop>
<!--- 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)>
1
<cfelse>
0
</cfif>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation