relative path problem

Problems with the Windows version of XAMPP, questions, comments, and anything related.

relative path problem

Postby kingfung_lam » 02. February 2009 18:29

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
kingfung_lam
 
Posts: 7
Joined: 30. January 2009 20:27

Re: relative path problem

Postby Wiedmann » 02. February 2009 18:47

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?)?
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: relative path problem

Postby kingfung_lam » 02. February 2009 18:51

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 ?)
kingfung_lam
 
Posts: 7
Joined: 30. January 2009 20:27

Re: relative path problem

Postby Wiedmann » 02. February 2009 19:50

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';".
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: relative path problem

Postby kingfung_lam » 02. February 2009 20:02

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
kingfung_lam
 
Posts: 7
Joined: 30. January 2009 20:27

Re: relative path problem

Postby Wiedmann » 02. February 2009 20:10

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").
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: relative path problem

Postby kingfung_lam » 02. February 2009 20:31

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.
kingfung_lam
 
Posts: 7
Joined: 30. January 2009 20:27

Re: relative path problem

Postby Wiedmann » 02. February 2009 20:34

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!
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: relative path problem

Postby kingfung_lam » 02. February 2009 20:37

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?
kingfung_lam
 
Posts: 7
Joined: 30. January 2009 20:27

Re: relative path problem

Postby Wiedmann » 02. February 2009 20:52

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).
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: relative path problem

Postby kingfung_lam » 02. February 2009 21:11

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 ?
kingfung_lam
 
Posts: 7
Joined: 30. January 2009 20:27

Re: relative path problem

Postby Wiedmann » 03. February 2009 07:43

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...)
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: relative path problem

Postby kingfung_lam » 03. February 2009 07:45

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
kingfung_lam
 
Posts: 7
Joined: 30. January 2009 20:27


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 52 guests