NYCPHP Meetup

[nycphp-talk] including an & in a variable

David Sklar sklar at sklar.com
Thu Jan 9 15:02:53 EST 2003


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