From what I have found doing a search I don't think this may be able to work on Win2000 but I will see if those brighter than I can confirm or deny it.
In my site I have an
include_once("php/headerad.php");
my Php scripts are in a folder php and documents in the root folder of the site work fine.
But I would like to put documents in subfolders of the site (we are a small newspaper and I would like to keep the sections seperate) like /sports/article1.php
When I try to change the script to:
include_once("www.mydomain.com/php/headerad.php");
include_once("http://mydomain.com/php/headerad.php");
I get the fun error:
Warning: main(http://www.mydomain.com/php/headerad.php): failed to open stream: No such file or directory
Is there a way to tell the script to find the .php outside of the current local directory?
TIA
Include_Once ???
Moderator: General Moderators
You can use periods to move up the directory structure.
For example, if you're currently on a page /sports/article1.php
I think that's what you're asking about.
For example, if you're currently on a page /sports/article1.php
Code: Select all
<?php
include_once('../php/headerad.php');
?>uber,
Good thought. I tried that and still get the error:
Warning: main(../php/headerad.php): failed to open stream: No such file or directory
In my root folder I have:
index.php
and folders
php/headerad.php
sports/index.php
With the include_once script of:
include_once("php/headerad.php");
the index page in the root folder is fine but anything in a lower folder directory can't find it.
Good thought. I tried that and still get the error:
Warning: main(../php/headerad.php): failed to open stream: No such file or directory
In my root folder I have:
index.php
and folders
php/headerad.php
sports/index.php
With the include_once script of:
include_once("php/headerad.php");
the index page in the root folder is fine but anything in a lower folder directory can't find it.
Well, I found this digging around...
include_once($DOCUMENT_ROOT . "../php/headerad.php");
Now the funny thing is the pages in sports/ folder pull the script fine.
But the index page in the root folder doesn't
If I can't find any work around, I will use this script and use a redirect html page to send my 'index' into a sub folder like the rest I guess.
Thanks for the effort uber.
include_once($DOCUMENT_ROOT . "../php/headerad.php");
Now the funny thing is the pages in sports/ folder pull the script fine.
But the index page in the root folder doesn't
If I can't find any work around, I will use this script and use a redirect html page to send my 'index' into a sub folder like the rest I guess.
Thanks for the effort uber.
Hmm, if it works with your docroot included, have you tried using root relative links (pay close attention)?
That beginning slash means it will look for a folder called 'php' in the root directory, no matter where you call it from. Try that.
Code: Select all
<?php
include_once('/php/headerad.php');
?>Tried that...
neither the doc in the root folder, nor the one in ths sub likes that one!
I have a feeling this is what I am running into...
Windows versions of PHP prior to PHP 4.3.0 do not support accessing remote files via this function, even if allow_url_fopen is enabled.
I think I only have 4.1 on the server. Dagnabit.
neither the doc in the root folder, nor the one in ths sub likes that one!
I have a feeling this is what I am running into...
Windows versions of PHP prior to PHP 4.3.0 do not support accessing remote files via this function, even if allow_url_fopen is enabled.
I think I only have 4.1 on the server. Dagnabit.