coldfusion - outputting variable in the URL -
I want to print my dates as variables in the URL:
I have the following url :
& lt; cfset urladdress = "https://abc.xyz.com/start_date=2013-04-01&end_date=2014-04-22&data_type=123"> I have set my dates as follows:
& lt; cfparam name = "startdate" default = "# dateFormat (dateAdd ('D' -1, now ()), 'yyyy-mm-dd') #" & gt; & Lt; Cfparam name = "enddate" default = "# date format (add date ('d', 0, now ()), 'yyyy-mm-dd' #" & gt; And now, I'm trying to print it like this:
& lt; cfset urladdress = "https://abc.xyz.com/start_date =" & lt; cfoutput & Gt; # StartDate # & lt; / cfoutput & gt; "& amp; end_date =" & lt; cfoutput & gt; # ENDDATE # & lt; / cfoutput & gt; "& amp; DATA_TYPE = 123" & gt; And I get the following error:
Invalid column was found on 123 column 123 in line 123. ColdFusion was looking at the following text: Lt; cfml compiler processing was: & Lt; launches a coldfusion tag. Do you mean LT or LTE? A seafet tag starting with column 2, column 2. Can I use the URL encod format function Need to use? inside
& lt; cfset & gt; & lt; cfset urladdress = "https://abc.xyz.com/start_date=#startdate#&end_date=#enddate#&data_type= 123" & gt; To protect you, you should use around (cf10 + only) or around the variable.
If you want to use encodeForURL () in CF9, check out:
Comments
Post a Comment