Variable in url via echo

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mattgnr
    New Member
    • May 2010
    • 5

    Variable in url via echo

    Hi,

    I am trying to use the SID tracking via Commission Junction to create a reward site.

    An example code banner display is:

    Code:
    <a href="http://www.jdoqocy.com/click-4011209-10677311?sid=$userid " target="_blank">
    <img src="http://www.lduhtrp.net/image-4011209-10677311" width="468" height="60" alt="Extend the life of your PC - Optimize your Slow PC" border="0"/></a>
    This is stored in my database which i then echo onto the page.

    I have decided $userid and this has already been called. However the url is not picking this up and instead just displays $userid rather than the number.

    Has anyone any suggestions?

    Many thanks!
  • zorgi
    Recognized Expert Contributor
    • Mar 2008
    • 431

    #2
    I can not be sure this is gonna work because you gave only small sample of your code but here it is:
    Code:
    <a href="http://www.jdoqocy.com/click-4011209-10677311?sid=<?php echo $userid;?> " target="_blank">

    Comment

    • mattgnr
      New Member
      • May 2010
      • 5

      #3
      Hi,

      Thanks - i'm not sure thats going to work as i can't call a php echo inside an echo can I?

      The code displayed on the page is simply:

      Code:
      <?php 
      $userid = 1;
      echo $row_Offers['html']; ?>

      Comment

      • zorgi
        Recognized Expert Contributor
        • Mar 2008
        • 431

        #4
        what is output when you echo $row_Offers['html']

        Comment

        • mattgnr
          New Member
          • May 2010
          • 5

          #5
          The original code I had in the first box:

          Code:
          
             1. <a href="http://www.jdoqocy.com/click-4011209-10677311?sid=$userid " target="_blank">
             2. <img src="http://www.lduhtrp.net/image-4011209-10677311" width="468" height="60" alt="Extend the life of your PC - Optimize your Slow PC" border="0"/></a>
          However the actual output on preview is the banner linking through to the url but instead of sid=1, it shows sid=$userid

          Comment

          • zorgi
            Recognized Expert Contributor
            • Mar 2008
            • 431

            #6
            Hm... so $row_Offers['html'] is puled from database? Why don't you simply change your <....?sid=$user id....> to <....?sid=1.... > in database?

            Comment

            • mattgnr
              New Member
              • May 2010
              • 5

              #7
              Originally posted by zorgi
              Hm... so $row_Offers['html'] is puled from database? Why don't you simply change your <....?sid=$user id....> to <....?sid=1.... > in database?
              Because the $userid is constantly being changed dependant on who log's in. (1 was just an example, $userid is actually pulled from a different table in the database). It's a rewards site so i need to be able to track the SID's in the links.

              Thanks!

              Comment

              • zorgi
                Recognized Expert Contributor
                • Mar 2008
                • 431

                #8
                I see. In that case you will find useful str_replace function. Variables do not just jump into the string. You need to place them there. The str_replace is your solution.

                Comment

                Working...