You are here: Re: include/require dircetive problem « All PHP « IT news, forums, messages
Re: include/require dircetive problem

Posted by Tyno Gendo on 04/08/07 23:30

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 ?

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация