Forum Moderators: coopster

Message Too Old, No Replies

$ SERVER['HTTP HOST'] problems

         

internetheaven

3:23 pm on Nov 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm very much a newbie at coding, had to take over rather quickly. I'm trying to display stats about my sites that are held in one database by inserting them onto the page, the information is called using the URL:

http://www.example.com/stats/request.php?tag=site

using file_get_contents where "stats" is a stripped out version of the website's URL. So, I created this:

<?php
$statsdomain = $_SERVER['HTTP_HOST'];
$statsdomainlink = str_replace("www.", "", $statsdomain);
$statsdomainlink = str_replace(".", "_", $statsdomainlink);
$file = file_get_contents ('http://www.example.com/stats/request.php?tag=.'$statsdomainlink');
Echo $file;
?>

where am I going wrong?

Any help would be appreciated.
Thanks
Mike

internetheaven

3:46 pm on Nov 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have come up with a workaround, is there an easier way?

<?php
$filename = $_SERVER['HTTP_HOST'];
$filename = str_replace("www.", "gggg", $filename);
$filename = str_replace(".", "_", $filename);
$filename = str_replace("gggg", "http://www.example.com/stats/request.php?tag=", $filename);
$file = file_get_contents ($filename);
Echo $file;
?>

londrum

3:51 pm on Nov 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



i think it's this line here. you might have the dot in the wrong place

$file = file_get_contents ('http://www.example.com/stats/request.php?tag=.'$statsdomainlink'); 

try this instead

$file = file_get_contents ('http://www.example.com/stats/request.php?tag='.$statsdomainlink);