I am really getting desperate now. Hopefully someone will manage to help me on this. I have created a clck.php page that redirects the users when they click on the banner to the URL of the advert. The purpose of the extra page (clck.php) is to enable me to track the clicks and assign them to the members. Then I connect the clck.php with the front site of the website by giving the url the following format: http:www.mysite.com/clck.php?lnk=URL. When I put the mouse on the banner it shows the full link but when you actually click on the banner it doeasn't take all the link. For example if the link is
[url]http://merchant.com&affid=xxx&refid=xxx&subaff=xxx[/url] it will only redirect you to : [url]http://merchant.com&affid=xxx[/url]. It won't pick up the rest of the URL although when i put the mouse on the link it does show on the explorer bar on the bottom the full link.

Here is the code.

The clck.php is:
<?php
include_once('./inc/default.inc');
$redir = $_GET['lnk'];
swomCreateClick("test", $redir);
header("Location:$redir");
?>

The relevant part from the default.inc is:

function swomCreateClick($username, $link)
{
global $MySQL_LinkID;
$merch_id = swomGetMerchantIDByURL($link);
$date = date("m/d/y");

if(!(mysql_query("INSERT INTO swomOpenClickList VALUES(NULL, '$username', '$merch_id', '$date', '0')")))
	echo(mysql_error());

}

I am really lost. Does anyone have any clue??

Thanks in advance

    run the url through urlencode and see if that helps

      Thanks for this. Would that go to the .ini file or the actual page that diplays the recordset?

        not exactly sure where in the code you would put this...just because everything is not laid out. but this might work for you.

        $redir = urlencode($_GET['lnk']);

          Thanks a lot. It didn't actually solve the problem but I really appreciate your time and your efford.

            try commenting out the redirect and echoing $redir

            (to make sure $redir is actually what you expect it to be)

              Hey,

              Thanks but it's still the same. Something that I forgot to say is that if I put a shorter URL like www.amazon.com it will pick it up and redirect normally it's when i put URL's of the type I describe above that does this problem. I am not sure if its because of the length of URL or the type.

                If I am wrong, I apologize, but thought I would suggest you taking another look at how you are formaing the urls with the merchants id and such appended to them.

                How is the "$link" variable being created? You told us, but could you show us? Because it is this that is giving you the problems I think when you try to access the value by $GET array value of lnk: "$redir = $GET['lnk']; "

                Can you show us THAT code?

                  Hello, thanks for that. I assume this is the code you need to see?

                  <a href="http://www.mysite.com/Admin/clck.php?lnk=<?php echo $row_rmerchants['MerchantURL']; ?>" target="_blank"><img src="<?php echo $row_rmerchants['MerchantImageURL']; ?>"

                  That is the code on the page that actually displays the recordset to the user to see.

                  I didn't assume that there was anything wrong with that since if i take the
                  "http://www.mysite.com/Admin/clck.php?lnk=" part out it works perfectly but of course its then not connected with the click page so there is no point taking this out.

                  I am really gratefull for all your suggestions thanks for being so helpul everyone.

                    Yes, that is it. But it is not the entire line of code. Can I see how you close the image tag, and, more importantly, the <a href> tag?

                    If you did the test that pjleonhardt suggested, namely 'echoing' out the value instead of redirecting, what were the results exactly? Were the q-strings chopped even when echoing them (or not)?

                    Also, let's take a look at actual data. Go into your DB and pull an example of the "$row_rmerchants['MerchantURL']" where the problem exists and show us exactly. (xxxx out the domain name only)

                    Lastly, had an idea for you to try using maxpup979's idea of encoding the url with the addition of another idea: creating a new variable for the functions and one for the redirect itself:

                    <?php
                    include_once('./inc/default.inc');
                    $redir = $lnk = $_GET['lnk'];
                    swomCreateClick("test", $lnk);
                    $redir = trim(urlencode($redir));
                    header("Location: $redir");
                    exit;
                    ?> 
                    

                      Deanp27: OK. Sorry about that. My idea was that something in one of your functions was messing up the url. My-bad.

                      Next, the url you supplied as example was automatically parsed and chopped so I can't see it fully. You have to re-copy and paste it in a new message (or edit the last) and then, before submitting it, go to additional options below the submit button and un-check the "Automatically parse links in text" option.

                        Sorry about the url. This should be ok now:

                        http://clkuk.tradedoubler.com/click?p=3289&a=1104411&g=13519630&epi=[email]

                        The only think i can suggest really is the fact there are 2 directions. First my page:
                        http://www.mysite.com/clck.php?lnk=
                        redrects to the above url which is the affiliates url which redirects to the merchants. Maybe this is causing the problem? I can't remember if i already said that but if i put a normal url lie amazon.com or msn.com it will redirect without any problem.

                          OK. Let's do a test using two simple files:

                          1)Index.php

                          <html>
                          <head><title>test</title></head>
                          <body>
                          <?php
                          // simulate a link like "$row_rmerchants['MerchantURL']"
                          $link = 'http://clkuk.tradedoubler.com/click?p=3289&a=1104411&g=13519630&epi=howdy@doody.com';
                          ?>
                          <p><a href="clck.php?lnk=<?php echo $link; ?>"><img src="moon.gif" /></a></p>
                          </body>
                          </html>
                          

                          2) clck.php

                          <?php
                          $redir = trim($_GET['lnk']);
                          // echo out the value per pjleonhardt
                          echo $redir;
                          ?>
                          

                          I upload and then clicky on that image. When I echo out the value of $redir, instead of: "http://clkuk.tradedoubler.com/click?p=3289&a=1104411&g=13519630&epi=howdy@doody.com"
                          I get this: "http://clkuk.tradedoubler.com/click?p=3289"

                          Let's try and header-redirect. I am taken here: http://clkuk.tradedoubler.com/click?p=3289 (an error page)

                          OK. Let's go back and change the first page to this:

                          <html>
                          <head><title>test</title></head>
                          <body>
                          <?php
                          $link = 'http://clkuk.tradedoubler.com/click?p=3289&a=1104411&g=13519630&epi=howdy@doody.com';
                          // URL encode the string per MaxPup
                          $link = urlencode($link);
                          ?>
                          <p><a href="clck.php?lnk=<?php echo $link; ?>"><img src="moon.gif" /></a></p>
                          </body>
                          </html>
                          

                          Clicky and echo "$redir": "http://clkuk.tradedoubler.com/click?p=3289&a=1104411&g=13519630&epi=howdy@doody.com"

                          And if I redirect from my site now, I am now redirected here: http://www.101cd.com/home/index.asp?asptnr=9691.

                          So, if you go back and change your code like this:

                          <?php
                          // url encode this value
                          $merchanturl = urlencode($row_rmerchants['MerchantURL']);
                          $merchimg = $row_rmerchants['MerchantImageURL'];
                          ?>
                          <p>
                          <a href="http://www.mysite.com/Admin/clck.php?lnk=<?php echo $merchanturl; ?>"><img src="<?php echo $merchimg; ?>" /></a>
                          </p>
                          

                          ... you should have no more trouble.

                            It's Working,

                            Thank you, thank you thank you. You can't imagine how big help is this for me. I had a designer who was helping me but took my money and left without finishing the project so now I am trying to solve all the problems he left me with. I solve most of them but couldn't solve this one. Thanks a million.

                              Write a Reply...