NameSilo

Php URLEncode help needed

Spacemail by SpaceshipSpacemail by Spaceship
Watch

deadhippo

Established Member
Impact
0
Hi, I have just set up a t-shirt ranking site. It is a free service but I had intended to add an affiliate code and it would pay for itself that way.
An I had done that or so I thought. I was able to add the affiliate code automatically to the script but I later found that the code was being stripped in the redirect.

The link I am using is as follows...except it is on one line. I broke it up so it wouldn't break up the page.

HTML:
 http://theshirtlist.com/cafepress/design_hit.php?
design_id=eccbc87e4b5ce2fe28308fd9f2a7baf3&
design_url=http://www.cafepress.com/deadhippo
/1201429&pid=xxxxxxx&tid=SL1

If you want to check out the link for yourself you can just look at my site - The Shirt List.

I was given the following piece of advice.
You haven't URL encoded the design_url value.
You won't be receiving any commission with that link. It's stripping away at the ampersand before pid. So all that gets passed to your redirect script is: http://www.cafepress.com/deadhippo/12014929

It should be formed like this:
HTML:
http%3A%2F%2Fwww%2Ecafepress%2Ecom%2Fdeadhippo
+%2F1201429%26pid%3Dxxxxxxx%26tid%3DSL1

You use a function called URLEncode to make the link look like that.

Then you need to decode it on your redirect script. Then redirect. And hey presto you redirect with a pid and a tid. No stripping away at the ampersand.

Unfortunately I don't know how to do this. If someone can help me I'd appreciate it.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
I'm not sure how you're getting the link, but where you want to use it, you can do:
PHP:
<?php 
echo urlencode('http://theshirtlist.com/cafepress/design_hit.php?...shortened');
?>
If you have it as a variable, do:
PHP:
<?php
echo urlencode($thevariable);
?>
 
0
•••
Hi,
Thanks for the reply. I don't know about php unfortunately but maybe you can tell me something more if I post the following code. There is some html mixed in there.

PHP:
<?
						$order_no = $order_no + 2;
						for($i=0;$i<2;$i++){
							$row_design[design_discription] = nl2br($row_design[design_discription]);
							$row_design[design_image] = "<a href='design_hit.php?design_id=$row_design[design_id]&design_url=$row_design[design_url]$site_pid' target='_blank'><img src='img/design/$row_design[design_image]' style='border-color:#FFFFFF; border-width:1px' align='absmiddle' alt='$site_word #: $row_design[design_code]
Member ID: $row_design[member_name]'>";
						  $design_order = $use_design_position ? $row_design['design_position'] : $order_no+$i;
						?>
						<td width="50%" align="left"><table width="294" height="275" border="0" style="PADDING-RIGHT: 1px; PADDING-LEFT: 1px; PADDING-BOTTOM: 1px; PADDING-TOP: 1px;" background="http://www.theshirtlist.com/images/thumb.gif">
                          <tr>
                            <td colspan="3" class="tsLink" align="center" height="23"><a href="design_hit.php?design_id=<?=$row_design[design_id]?>&design_url=<?=$row_design[design_url]?><?=$site_pid?>" class="tsLink" target="_blank"><?= htmlspecialchars($row_design[design_title]) ?></a></td>

The code just before $site_pid and <?=$site_pid?> is the where the url appears. The $site_pid and <?=$site_pid?> is how I added my affiliate and tracking code. The second piece of code I am proud to say is the first piece of php code I ever wrote, even though it is a pretty humble achievement.

I realise that this may be a very difficult question so don't be afraid to tell me I am asking too much. On the other hand if you are able to help me that would be great.
 
0
•••
deadhippo said:
Hi,
Thanks for the reply. I don't know about php unfortunately but maybe you can tell me something more if I post the following code. There is some html mixed in there.

PHP:
<?
						$order_no = $order_no + 2;
						for($i=0;$i<2;$i++){
							$row_design[design_discription] = nl2br($row_design[design_discription]);
							$row_design[design_image] = "<a href='design_hit.php?design_id=$row_design[design_id]&design_url=$row_design[design_url]$site_pid' target='_blank'><img src='img/design/$row_design[design_image]' style='border-color:#FFFFFF; border-width:1px' align='absmiddle' alt='$site_word #: $row_design[design_code]
Member ID: $row_design[member_name]'>";
						  $design_order = $use_design_position ? $row_design['design_position'] : $order_no+$i;
						?>
						<td width="50%" align="left"><table width="294" height="275" border="0" style="PADDING-RIGHT: 1px; PADDING-LEFT: 1px; PADDING-BOTTOM: 1px; PADDING-TOP: 1px;" background="http://www.theshirtlist.com/images/thumb.gif">
                          <tr>
                            <td colspan="3" class="tsLink" align="center" height="23"><a href="design_hit.php?design_id=<?=$row_design[design_id]?>&design_url=<?=$row_design[design_url]?><?=$site_pid?>" class="tsLink" target="_blank"><?= htmlspecialchars($row_design[design_title]) ?></a></td>

The code just before $site_pid and <?=$site_pid?> is the where the url appears. The $site_pid and <?=$site_pid?> is how I added my affiliate and tracking code. The second piece of code I am proud to say is the first piece of php code I ever wrote, even though it is a pretty humble achievement.

I realise that this may be a very difficult question so don't be afraid to tell me I am asking too much. On the other hand if you are able to help me that would be great.

First Change:
PHP:
$row_design[design_image] = "<a href='design_hit.php?design_id=$row_design[design_id]&design_url=$row_design[design_url]$site_pid' target='_blank'><img src='img/design/$row_design[design_image]' style='border-color:#FFFFFF; border-width:1px' align='absmiddle' alt='$site_word #: $row_design[design_code]
:: Change To ::
PHP:
$row_design[design_image] = "<a href='design_hit.php?design_id=$row_design[design_id]&design_url=" . urlencode($row_design[design_url]) . "$site_pid' target='_blank'><img src='img/design/$row_design[design_image]' style='border-color:#FFFFFF; border-width:1px' align='absmiddle' alt='$site_word #: $row_design[design_code]

Second Change:
PHP:
<td colspan="3" class="tsLink" align="center" height="23"><a href="design_hit.php?design_id=<?=$row_design[design_id]?>&design_url=<?=$row_design[design_url]?><?=$site_pid?>" class="tsLink" target="_blank"><?= htmlspecialchars($row_design[design_title]) ?></a></td>
:: Change To ::
PHP:
<td colspan="3" class="tsLink" align="center" height="23"><a href="design_hit.php?design_id=<?=$row_design[design_id]?>&design_url=<?=urlencode($row_design[design_url])?><?=$site_pid?>" class="tsLink" target="_blank"><?= htmlspecialchars($row_design[design_title]) ?></a></td>

Hope this helps ;)
 
0
•••
Dynadot — .com Registration $8.99Dynadot — .com Registration $8.99
Appraise.net

We're social

Unstoppable Domains
Domain Recover
NameMaxi - Your Domain Has Buyers
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back