NYCPHP Meetup

NYPHP.org

[nycphp-talk] including an & in a variable

Jaz-Michael King JMKing at ipro.org
Thu Jan 9 15:31:43 EST 2003


So right now I have to point to dozens of pages like thi sone:
http://www.medicare.gov/NHCompare/Search/HomeSelect.asp?State=NY1%7CNew+York+-+Upstate&Type=County&County=33060%7CChautauqua

So I use

href="http://www.ipro.org/redirect.php?redir=http://www.medicare.gov/NHCompare/Search/HomeSelect.asp?State=NY1%7CNew+York+-+Upstate&Type=County&County=33060%7CChautauqua"

which counts the click and forwards the user (except for stopping at "&Upstate")

but you're saying now I would need
<?
$redir = 'http://www.medicare.gov/NHCompare/Search/HomeSelect.asp?State=NY1%7CNew+York+-+Upstate&Type=County&County=33060%7CChautauqua'
?>
...
href="http://www.ipro.org/redirect.php?redir=<?= urlencode($redir) ?>"
...

for each link?


>>> sklar at sklar.com 01/09/03 03:02PM >>>
Use urlencode() to encode the URLs being passed to the link tracker.

E.g. do this:

$redir = 'http://www.domain.com?state=ny&county=kings';
print '<a href="'.urlencode($redir).'">click here</a>.';

Instead of this:

$redir = 'http://www.domain.com?state=ny&county=kings';
print '<a href="'.$redir.'">click here</a>.';


-dave


> -----Original Message-----
> From: Jaz-Michael King [mailto:JMKing at ipro.org] 
> Sent: Thursday, January 09, 2003 2:39 PM
> To: NYPHP Talk
> Subject: [nycphp-talk] including an & in a variable
> 
> 
> hi all
> 
> I'm trying to pass a bunch of long urls to a script as a link tracker
> but the urls contain ampersands. so, if I want to track the link
> www.domain.com?state=ny&county=kings 
> 
> my script stops at the ampersand - I assume I have to escape it somehow?
> 
> if (!isset($redir)) 
>     die("Sorry, that link is bad. Please go back and try a 
> different link.");
> 
> if (!isset($referrer)) {
>     if (!isset($HTTP_REFERER)) {
>         $referrer = "none";
>     } else {
>         $referrer = $HTTP_REFERER;
>     };
> };
> 
> if (!isset($REMOTE_ADDR)) {
>     $remotehost = "no client address";
> } else {
>     $remotehost = $REMOTE_ADDR;
> };
> 
> $timeused = date("Y-m-d H:i:s",time());
> 
> @mysql_db_query($db_data , "insert into $db_table 
> values('$redir','$referrer',
>     '$remotehost','$timeused')");
> 
> Header("Location: $redir");
> exit;
> 
> thanks much,
> jaz
> 
> ******************************
> Jaz-Michael King
> Online Services Manager
> IPRO
> http://ipro.org 
> ******************************
> 
> 
> 
> 
> 
> 
> 


--- Unsubscribe at http://nyphp.org/list/ ---







More information about the talk mailing list