Page 1 of 1

href & php

Posted: Mon Mar 07, 2011 8:34 am
by infrabyte
Hi,

I have a php file index.php that does a request to an add server as follows:

<?php
$BSMRT="75B1BE1F-C62B-2C35-3E48-D7B4D4FA5B97";
$ENDPOINT="http://www.addserver.net/ad_server/request";
$url="$ENDPOINT?adsiid=$BSMRT&mrkup=xhtml";
$adcode=file_get_contents($url);
?>

<?=$adcode ?>

This works on a normal server with php but the server this has to pass through has a "bot proxy". What I need to do is when the user clicks on the addserver image that it opens up in a new web page similar to onclick...

I must use <a href=" .... "></a> for the server to accept the code.

How do I put $adcode in the <a href syntax?
I've been trying this for days now and any help would be much appreciated.
Thanx in advance

Re: href & php

Posted: Mon Mar 07, 2011 10:23 am
by social_experiment

Code: Select all

<?php
$BSMRT="75B1BE1F-C62B-2C35-3E48-D7B4D4FA5B97";
$ENDPOINT="http://www.addserver.net/ad_server/request";
$url="$ENDPOINT?adsiid=$BSMRT&mrkup=xhtml";
$encodedURL = urlencode($url);

echo '<a href="' . $encodedURL . '">Link Name</a>';
?>
That should give a url named 'Link Name' (sub that for your link name) that goes to the page http://your.addy//.
You may also have to use urlencode with file_get_contents.
The manual wrote: If you're opening a URI with special characters, such as spaces, you need to encode the URI with urlencode().
Hth
EDIT
Changed the $adcode to $url

Re: href & php

Posted: Tue Mar 08, 2011 1:28 am
by infrabyte
Thank you,

I will try this and get back...

Re: href & php

Posted: Tue Mar 08, 2011 4:50 am
by infrabyte
This doesn't work. It places the whole url in the page instead of the image it is supposed to get from the server.

Re: href & php

Posted: Tue Mar 08, 2011 10:19 am
by social_experiment
infrabyte wrote:...addserver image...
By image, what do you mean. image = picture?