include/require dircetive problem

Hi,
can anyone tell me what's wrong with the following code:
==================================================
<?php
echo "Hello this is a test file on my server Seen: ${_POST['seen']} </
br>";

if(!isset($_POST['seen']) )
{
echo "HERE..."; $_POST['seen'] = 'yes';
require $_SERVER['SCRIPT_FILENAME'];
}
else{
echo "Not here...";
}echo "At the end of script ";

?>
==================================================
Basically, the idea was that the script should include/require
itself
at some condition, at the end of the script.
While it works fine on my home server and prints out

Hello this is a test file on my server Seen:
HERE...Hello this is a test file on my server Seen: yes
Not here...At the end of script At the end of script

on my hosting provider server it does not work as expected, i.e. the
include does not happen. The output will be:

Hello this is a test file on my server Seen:
HERE...

Any help would be greatly appreciated,
Igor.
igorp [ So, 08 April 2007 20:08 ] [ ID #1681769 ]

Re: include/require dircetive problem

igorp wrote:
> Hi,
> can anyone tell me what's wrong with the following code:
> ==================================================
> <?php
> echo "Hello this is a test file on my server Seen: ${_POST['seen']} </
> br>";
>
> if(!isset($_POST['seen']) )
> {
> echo "HERE..."; $_POST['seen'] = 'yes';
> require $_SERVER['SCRIPT_FILENAME'];
> }
> else{
> echo "Not here...";
> }echo "At the end of script ";
>
> ?>
> ==================================================
> Basically, the idea was that the script should include/require
> itself
> at some condition, at the end of the script.
> While it works fine on my home server and prints out
>
> Hello this is a test file on my server Seen:
> HERE...Hello this is a test file on my server Seen: yes
> Not here...At the end of script At the end of script
>
> on my hosting provider server it does not work as expected, i.e. the
> include does not happen. The output will be:
>
> Hello this is a test file on my server Seen:
> HERE...
>
> Any help would be greatly appreciated,
> Igor.
>

Try print_r($_SERVER["SCRIPT_FILENAME"]); and make sure you are getting
a file path as expected on the remote host and $_SERVER is working ok,
might be an old version of PHP on the hosting server.

You could also try PHP_SELF var as the script is calling itself so you
shouldn't need to worry about a path.

include($_SERVER["PHP_SELF"]);
or
include("./" . $_SERVER["PHP_SELF"]);

if its a really old PHP on the hosting server it might use registered
globals... eg. $PHP_SELF ?
Tyno Gendo [ Mo, 09 April 2007 01:30 ] [ ID #1682465 ]

Re: include/require dircetive problem

On Apr 9, 1:30 am, Tyno Gendo <u... [at] example.com> wrote:
> igorp wrote:
> > Hi,
> > can anyone tell me what's wrong with the following code:
> > ==================================================
> > <?php
> > echo "Hello this is a test file on my server Seen: ${_POST['seen']} </
> > br>";
>
> > if(!isset($_POST['seen']) )
> > {
> > echo "HERE..."; $_POST['seen'] = 'yes';
> > require $_SERVER['SCRIPT_FILENAME'];
> > }
> > else{
> > echo "Not here...";
> > }echo "At the end of script ";
>
> > ?>
> > ==================================================
> > Basically, the idea was that the script should include/require
> > itself
> > at some condition, at the end of the script.
> > While it works fine on my home server and prints out
>
> > Hello this is a test file on my server Seen:
> > HERE...Hello this is a test file on my server Seen: yes
> > Not here...At the end of script At the end of script
>
> > on my hosting provider server it does not work as expected, i.e. the
> > include does not happen. The output will be:
>
> > Hello this is a test file on my server Seen:
> > HERE...
>
> > Any help would be greatly appreciated,
> > Igor.
>
> Try print_r($_SERVER["SCRIPT_FILENAME"]); and make sure you are getting
> a file path as expected on the remote host and $_SERVER is working ok,
> might be an old version of PHP on the hosting server.
>
> You could also try PHP_SELF var as the script is calling itself so you
> shouldn't need to worry about a path.
>
> include($_SERVER["PHP_SELF"]);
> or
> include("./" . $_SERVER["PHP_SELF"]);
>
> if its a really old PHP on the hosting server it might use registered
> globals... eg. $PHP_SELF ?


Hi,
here is an update -
I've found that the problem is connected to the version of the PHP
used running this script. If the script runs under PHP 4.4.6 at my
hos provider server - it does just fine (it also works well at my
desktop -
Windows w. PHP 5.2.0 ) but with v. 5.2.1 it fails and causes a coe
dump ....
and causes php5.bin to create a core file.

Igor
igorp [ Mo, 09 April 2007 10:03 ] [ ID #1682469 ]
PHP » alt.php » include/require dircetive problem

Vorheriges Thema: PHPSESSIONID
Nächstes Thema: An Easy One for you all