Skip to main content
Participant
February 4, 2011
Question

Problems with passing variable

  • February 4, 2011
  • 3 replies
  • 416 views

Hi Folks


I am working on a forum for a customer and I am having problems passing a url variable;
This the code i have on a search page
<cfelseif cgi.http_referer contains 'forumViewMessages'><cfset linktext = 'Forum Postings/Replies Page'><cfset lastpage = 'forumViewMessages.cfm?#linkVariables#'>
</cfif>
<cfoutput>#lastpage#</cfoutput>
<cfabort>
the output on the page when i run this is;
forumViewMessages.cfm?topicID=284&catID=8&category=Bird Breeding

When the form is submitted to the results page;
<form name="form1" method="post" action="forumsearchresults.cfm?lastpage=<cfoutput>#lastpage#</cfoutput>">

it shows in the status bar that ALL the variables are being passed, so up to here is OK.

Where my problem starts is when i get to the results page and when i run;
<cfoutput>#url.lastpage#</cfoutput>
<cfabort>
on that page the output page shows just;
forumViewMessages.cfm?topicID=284

Can anyone please explain or give me a reason why the whole string is not being passed. Does it have anything to do with the ampersand after the topicID (topicID=284&)

Your help would be greatly appreciated
thanks in advance
Grabit
    This topic has been closed for replies.

    3 replies

    Inspiring
    February 5, 2011

    If you are passing values in the URL string which themselves contain symbols that are meaningful in the context of a URL (eg: ampersands, etc), then you need to URL encode the value to "escape" those "special" characters, so they are considered a URL parameter value, not as part of the URL itself.

    --

    Adam

    BKBK
    Community Expert
    Community Expert
    February 5, 2011

    Woolyziggy wrote:


    Can anyone please explain or give me a reason why the whole string is not being passed.

    The whole string is in fact passed. However, the URL structure comprises key/value pairs that are delimited by the ampersand (&) symbol. So, the query-string

    lastpage=forumViewMessages.cfm?topicID=284&catID=8&category=Bird Breeding

    actually comprises the following 3 URL key/value pairs

    lastpage=forumViewMessages.cfm?topicID=284

    catID=8

    category=Bird Breeding

    To see this, use <cfdump var="#URL#">. This is not a bad thing, if you're only interested in getting the individual values.

    However, to get the entire query string, I would simply use CGI.QUERY_STRING, as Dan has said, rather than loop through the URL structure.

    Inspiring
    February 4, 2011

    cgi.query_string might be a more helpful variable.