Connecting Tech Pros Worldwide Forums | Help | Site Map

include problem

meredith
Guest
 
Posts: n/a
#1: Jul 17 '05
I'm running Debian Linux stable and PHP 4.1.2. My include_path is

'.:/php/includes:/usr/local/lib/php/:/usr/local/lib/php/smarty/'

Problem is,

include('/includes/foo.php');

doesn't work, returning a Failed opening error. If I put in the full
path, it works just fine. Do site-based absolute paths not work in
general, or is it a version problem, or what?
--
msnomer
=======
Cool free games and much more here:
http://www.neopets.com/refer.phtml?username=msnomer

Jan Pieter Kunst
Guest
 
Posts: n/a
#2: Jul 17 '05

re: include problem


In article
<msnomer-160676.15384905042004@dsl254-095-101.nyc1.dsl.speakeasy.net>,
meredith <msnomer@spamcop.net> wrote:
[color=blue]
> include('/includes/foo.php');
>
> doesn't work, returning a Failed opening error. If I put in the full
> path, it works just fine. Do site-based absolute paths not work in
> general, or is it a version problem, or what?[/color]

The root of an absolute path in a PHP script is the 'real' filesystem
root, not the web server's 'document root'.

JP

--
Sorry, <devnull@cauce.org> is een "spam trap".
E-mail adres is <jpk"at"akamail.com>, waarbij "at" = @.
meredith
Guest
 
Posts: n/a
#3: Jul 17 '05

re: include problem


In article <devnull-EC2171.21431705042004@news1.news.xs4all.nl>,
Jan Pieter Kunst <devnull@cauce.org> wrote:
[color=blue]
> In article
> <msnomer-160676.15384905042004@dsl254-095-101.nyc1.dsl.speakeasy.net>,
> meredith <msnomer@spamcop.net> wrote:
>[color=green]
> > include('/includes/foo.php');
> >
> > doesn't work, returning a Failed opening error. If I put in the full
> > path, it works just fine. Do site-based absolute paths not work in
> > general, or is it a version problem, or what?[/color]
>
> The root of an absolute path in a PHP script is the 'real' filesystem
> root, not the web server's 'document root'.
>
> JP[/color]

Well, how annoying! So the only way to put in an absolute path (which is
necessary for subdirectories) is the append the "real" root? Bletch!
--
msnomer
=======
Cool free games and much more here:
http://www.neopets.com/refer.phtml?username=msnomer
Pedro Graca
Guest
 
Posts: n/a
#4: Jul 17 '05

re: include problem


meredith wrote:[color=blue]
> Well, how annoying! So the only way to put in an absolute path (which is
> necessary for subdirectories) is the append the "real" root? Bletch![/color]

You can do:
include $_SERVER['DOCUMENT_ROOT'] . '/include/foo.php';
--
USENET would be a better place if everybody read: : mail address :
http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
http://www.expita.com/nomime.html : to 10K bytes :
Yannick Turgeon
Guest
 
Posts: n/a
#5: Jul 17 '05

re: include problem


Just to make sure there is no misunderstanding. You can specify a file from
a subdirectory relatively (and not absolute). In your situation, if the
directory "includes" is a sibling of your main file you can include foo.php
like that:
include('includes/foo.php') (Without the leading slash)

HTH

Yannick

"meredith" <msnomer@spamcop.net> wrote in message
news:msnomer-1569B1.15585705042004@dsl254-095-101.nyc1.dsl.speakeasy.net...[color=blue]
> In article <devnull-EC2171.21431705042004@news1.news.xs4all.nl>,
> Jan Pieter Kunst <devnull@cauce.org> wrote:
>[color=green]
> > In article
> > <msnomer-160676.15384905042004@dsl254-095-101.nyc1.dsl.speakeasy.net>,
> > meredith <msnomer@spamcop.net> wrote:
> >[color=darkred]
> > > include('/includes/foo.php');
> > >
> > > doesn't work, returning a Failed opening error. If I put in the full
> > > path, it works just fine. Do site-based absolute paths not work in
> > > general, or is it a version problem, or what?[/color]
> >
> > The root of an absolute path in a PHP script is the 'real' filesystem
> > root, not the web server's 'document root'.
> >
> > JP[/color]
>
> Well, how annoying! So the only way to put in an absolute path (which is
> necessary for subdirectories) is the append the "real" root? Bletch!
> --
> msnomer
> =======
> Cool free games and much more here:
> http://www.neopets.com/refer.phtml?username=msnomer[/color]


RT
Guest
 
Posts: n/a
#6: Jul 17 '05

re: include problem


I had the same problem yesterday and found that if I did the following it
worked - include('../../includes/foo.php') for some reason putting 2 ..
Then the slash / makes it function properly.

RT

On 4/5/04 4:06 PM, in article Y_icc.13644$wq4.665840@news20.bellglobal.com,
"Yannick Turgeon" <nobody@nowhere.com> wrote:
[color=blue]
> Just to make sure there is no misunderstanding. You can specify a file from
> a subdirectory relatively (and not absolute). In your situation, if the
> directory "includes" is a sibling of your main file you can include foo.php
> like that:
> include('includes/foo.php') (Without the leading slash)
>
> HTH
>
> Yannick
>
> "meredith" <msnomer@spamcop.net> wrote in message
> news:msnomer-1569B1.15585705042004@dsl254-095-101.nyc1.dsl.speakeasy.net...[color=green]
>> In article <devnull-EC2171.21431705042004@news1.news.xs4all.nl>,
>> Jan Pieter Kunst <devnull@cauce.org> wrote:
>>[color=darkred]
>>> In article
>>> <msnomer-160676.15384905042004@dsl254-095-101.nyc1.dsl.speakeasy.net>,
>>> meredith <msnomer@spamcop.net> wrote:
>>>
>>>> include('/includes/foo.php');
>>>>
>>>> doesn't work, returning a Failed opening error. If I put in the full
>>>> path, it works just fine. Do site-based absolute paths not work in
>>>> general, or is it a version problem, or what?
>>>
>>> The root of an absolute path in a PHP script is the 'real' filesystem
>>> root, not the web server's 'document root'.
>>>
>>> JP[/color]
>>
>> Well, how annoying! So the only way to put in an absolute path (which is
>> necessary for subdirectories) is the append the "real" root? Bletch!
>> --
>> msnomer
>> =======
>> Cool free games and much more here:
>> http://www.neopets.com/refer.phtml?username=msnomer[/color]
>
>[/color]

Closed Thread


Similar PHP bytes