Page 1 of 1

relative path problem

PostPosted: 02. February 2009 18:29
by kingfung_lam
Hi,
I keep ahving a releative path problem. When I go up one level , let say INclude("../abc.php"), it will give me an error :
Failed opening included 'abc.php'
(include_path='.;C:\xampp\php\pear\') in C:\xampp\htdocs\Project\Display.php on line 57

However, it works fine if I put the file under the same directory , or any sub directory.

Please hlep

Re: relative path problem

PostPosted: 02. February 2009 18:47
by Wiedmann
Please hlep

Too less information to help....

let say INclude("../abc.php"), it will give me an error :
Code: Select all
Failed opening included 'abc.php' (include_path='.;C:\xampp\php\pear\') in C:\xampp\htdocs\Project\Display.php on line 57

- What is the filesystem location for both files?
- Which file did you access in your browser with which uri (and what is the filesystem location from this files?)?

Re: relative path problem

PostPosted: 02. February 2009 18:51
by kingfung_lam
I am using windows .
abc.php is located in c:\xampphtdocs\
while C:\xampp\htdocs\Project\Display.php is trying to include it.
URL is http://localhost/project/Display.php

it will show me an error like the description above. (Do I need to change anything in the php.ini ?)

Re: relative path problem

PostPosted: 02. February 2009 19:50
by Wiedmann
Code: Select all
Failed opening included 'abc.php'... in C:\xampp\htdocs\Project\Display.php ...

abc.php is located in c:\xampp\htdocs\
while C:\xampp\htdocs\Project\Display.php is trying to include it.
URL is http://localhost/project/Display.php

This error message is from a "include 'abc.php';", but you need a "include '../abc.php';".

Re: relative path problem

PostPosted: 02. February 2009 20:02
by kingfung_lam
what i mean was... if I put it in the same directory while changing the statement to INclude("abc.php"), then it will work.
If I put it in an upper level and use Include("../abc.php"), then it will fail and show the error above

Re: relative path problem

PostPosted: 02. February 2009 20:10
by Wiedmann
If I put it in an upper level and use Include("../abc.php"), then it will fail and show the error above

As I wrote in my last post:
The above error message is from a Include("abc.php") and not from a Include("../abc.php")
--> Thus you can't have the above error message with a Include("../abc.php").

Re: relative path problem

PostPosted: 02. February 2009 20:31
by kingfung_lam
Wiedmann wrote:
If I put it in an upper level and use Include("../abc.php"), then it will fail and show the error above

As I wrote in my last post:
The above error message is from a Include("abc.php") and not from a Include("../abc.php")
--> Thus you can't have the above error message with a Include("../abc.php").



OK, let me Clear it up again.......

I have Folder structure
Htdocs -> abc.php
Htdocs ->Project
Htdocs ->Project -> Display.php
Htdocs ->Project -> abc.php


where abc.php is a simple file contain <?php echo "Hello"; ?>


I am trying to run display.php http://localhost/project/Display.php

There is one include statement in display.php.
I tried to test it with Include("abc.php");, it works fine
I tried to test it with Include("../abc.php"), then it gives me the error above.



It is not a particular problem. I Have the same problem to ALLL scripts where I need to Include/Reference a file in upper directory level.

Re: relative path problem

PostPosted: 02. February 2009 20:34
by Wiedmann
I tried to test it with Include("../abc.php"), then it gives me the error above.

The last try:
The above error message is not from this include statement!

Re: relative path problem

PostPosted: 02. February 2009 20:37
by kingfung_lam
Wiedmann wrote:
I tried to test it with Include("../abc.php"), then it gives me the error above.

The last try:
The above error message is not from this include statement!




Then can you tell me why I can't do reference (include , require , include_once, require_once) to any file in upper directory level?

Re: relative path problem

PostPosted: 02. February 2009 20:52
by Wiedmann
Then can you tell me why I can't do reference (include , require , include_once, require_once) to any file in upper directory level?

Because you don't do this in this script (the script which apache is executing).

Re: relative path problem

PostPosted: 02. February 2009 21:11
by kingfung_lam
Wiedmann wrote:
Then can you tell me why I can't do reference (include , require , include_once, require_once) to any file in upper directory level?

Because you don't do this in this script (the script which apache is executing).



So you mean

<?php

Include("../abc.php");

?>

Is invalid in apache ?

Re: relative path problem

PostPosted: 03. February 2009 07:43
by Wiedmann
So you mean
Code: Select all
<?php Include("../abc.php"); ?>

Is invalid in apache ?

No, I don't mean this. I mean:
This code is not in the script which apache is executing. (Maybe you are editing a wrong script...)

Re: relative path problem

PostPosted: 03. February 2009 07:45
by kingfung_lam
Wiedmann wrote:
So you mean
Code: Select all
<?php Include("../abc.php"); ?>

Is invalid in apache ?

No, I don't mean this. I mean:
This code is not in the script which apache is executing. (Maybe you are editing a wrong script...)



so how can I execute a script that is in upper folder ?
I am 200 % sure that is there. This problem occur in the whole site. Whenever I do a reference to upper folder , it shows me that error message