Include and php_self

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hello again,

I have a page visit tracker script created after a video tutorial on writing
your own tracker.
// consider dbconnection already in place
$page = $_SERVER["PHP_SELF"];
$date_auto = time ();
$query = "INSERT INTO tracker (page, IP, date_auto ) VALUES ('$page', '$IP',
mysql_query ($query, $db_connection);
mysql_close ($db_connection);

In the pages I want to track according to the tut all I have to do is add
<?php include (' '); ?>

So I did. The weird bit is: in the tutorial the db lists the calling page's
name as PHP_SELF, but in my version it always shows the name of the
tracker.php script itself. I know I can use http_referer to get the info
about the page anyway, but can anyone explain WHY these results differ ? My
script is basically an identical copy of the tutorial script...


Re: Include and php_self

Pjotr Wedersteers wrote:
Quoted text here. Click to load it

$_SERVER['PHP_SELF'] always contains the name of the file that includes
other files, or the file itself when it's retrieved from a remote source
(like in your case).

The tutorial probably uses PHP_SELF as an example value to indicate the page

BTW, another worakround would be to define the page variable before

    $page = "tracker.php";
    include (" =$page");


Re: Include and php_self

Janwillem Borleffs wrote:
Quoted text here. Click to load it
Thanks, that cleared up that mystery. Remote file. I was stomped. No more!

Site Timeline