Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Current Url in Variable?

10:35 am on Apr 26, 2007 (gmt 0)

Preferred Member

10+ Year Member

joined:Mar 4, 2004
votes: 0

Ok this is my problem.

I have a script I am using as an include in many sites. It pulls info from a database and displays ads. Now every site that this is displayed on has an ad in the database and I dont want anyones ads showing on their own site.

I wrote this.

##$current = $_SERVER["HTTP_HOST"];
$current = $_SERVER['PHP_SELF'];

$lin = mysql_query("SELECT * FROM link order by id asc", $link) or die ("query 1: " . mysql_error());
echo '<li><h2>LinkWork</h2>'
. '<ul>';
while ($li = mysql_fetch_array($lin)) {
if ($current == $li['base'])
echo '';
echo '<li><a href="'.$li['web_url'].'" alt="'.$li['alt_tag'].'">'.$li['display'].'</a></li>';


The column base, is the base of a url eg. #*$!.com

So that is what I need to find, a php variable that gives me the current pages web address, but only up to the end of the com or org.

12:01 pm on Apr 26, 2007 (gmt 0)


WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 24, 2001
votes: 0

you can use one of the $_SERVER [php.net] vars and then use parse_url() [php.net]