Skip navigation
Currently Being Moderated

passing two URL variables

Nov 27, 2012 1:02 PM

Hi,

 

I'm working on a page like this:

http://mymindsnotright.com/discussionGenReplies.cfm?post_id=22

and am trying to make it so the link for each "Post Reply" link (save for the "Post Reply" link below the main topic) adds another url variable after the post_id variable.  The new variable I want to add would be the "user_id" for each reply, so each "Post Reply" link is specific to the person who posted the reply...

 

basically, I want it to look like this after lcikcing one of the "Post Reply" link

http://mymindsnotright.com/discussionGenReplies.cfm?post_id=22&user_id =(the user id of the person who posted the reply)#replytest 

               (the link doesn't go to a new page but rather to a named anchor lower down on the page)

 

The closest I can get is with this:

<a href="?post_id=<cfoutput>#rsGenPost.post_id#</cfoutput>&user_id=<cfou tput>#rsGenReplies.user_id#</cfoutput>##replytest" class="redlink"><strong>Post Reply</strong></a>

 

but when I click that link, I get this:

http://localhost:8500/Htdocs/discussionGenReplies.cfm?post_id=10101010 10101010&user_id=23411111#replytest

 
Replies
  • Currently Being Moderated
    Nov 27, 2012 1:18 PM   in reply to wycks

    @wycks,

    Not sure why the post_id is outputting twice, but that code can be cleaned up a bit.  Remove the inner </cfoutput> and <cfoutput> tags so it looks more like this:

     

    <a href="?post_id=<cfoutput>#rsGenPost.post_id#&user_id=#rsGenReplies.us er_id#</cfoutput>##replytest" class="redlink"><strong>Post Reply</strong></a>

     

    I am assuming rsGenPost is a query?  If so, are there multiple rows returned in that query (that may have the same post_id value repeated)?

    -Carl V.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 27, 2012 1:55 PM   in reply to wycks

    Maybe it would help to see more of your code, including the queries, and especially whatever surrounds the line you referenced in your original post.

    -Carl V.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 27, 2012 3:13 PM   in reply to wycks

    I often find it neater to place the cfoutput tag outside double quotes, like this:

     

    <cfoutput><a href="?post_id=#rsGenPost.post_id#&user_id=#rsGenReplies.user_id###re plytest" class="redlink"></cfoutput><strong>Post Reply</strong></a>

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 27, 2012 3:23 PM   in reply to BKBK

    I was going to recommend that instead of what I posted, but didn't want to have to get into explaining escaping the hash/pound symbols that weren't part of the variable outputs.  Oh well...

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 28, 2012 11:33 AM   in reply to wycks

    Users log in to your site. It is therefore a simple matter to obtain the user_id of the current user. You know who the current user is. For example, getAuthUser(). If necessary, you can run a query to find the corresponding user_id.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 28, 2012 12:25 PM   in reply to wycks

    wycks wrote:

     

    ... when I try to take it a step further with this:

         <a href="discussionGenReplies.cfm?post_id=#rsGenReplies.post_id#&#user_i d=#rsGenReplies.user_id#" class="redlink"><strong>Post Reply</strong></a>

     

    I get an error: 

    Invalid CFML construct found on line 294 at column 74.

    ColdFusion was looking at the following text:

    =

    There is an extraneous # just before user_id.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points