Page 1 of 1

Relative paths using include() - not working

PostPosted: 01. February 2009 23:01
by kevinmack18
I am having issues with relative paths using Xampp.

Code: Select all
Warning: include("BLAH BLAH") [function.include]: failed to open stream: No such file or directory in "BLAH BLAH"
Warning: include() [function.include]: Failed opening '"BLAH BLAH"' for inclusion (include_path='.;C:\xampp\php\pear\') in "BLAH BLAH"


Is this something I can fix in the php.ini? Or is this just a Windows issue with relative paths? -- if so, what can I do to fix this?

I keep trying everything // Does anyone else have this issue? Or have you ever had this issue?

(I am using Windows XP Pro)


Hope someone can help! Thanks in advance.

Re: Relative paths using include() - not working

PostPosted: 01. February 2009 23:14
by Izzy
In xampp\apache\bin\php.ini
Code: Select all
;;;;;;;;;;;;;;;;;;;;;;;;;
; Paths and Directories ;
;;;;;;;;;;;;;;;;;;;;;;;;;

; UNIX: "/path1:/path2"
;include_path = ".:/php/includes"
;
; Windows: "\path1;\path2"
include_path = ".;C:\xampp2\php\pear\"

Re: Relative paths using include() - not working

PostPosted: 01. February 2009 23:49
by Wiedmann
Code: Select all
Warning: include("BLAH BLAH") [function.include]: failed to open stream: No such file or directory in "BLAH BLAH"

Or have you ever had this issue?

No, i don't have a PHP file with the name "BLAH BLAH" and have never tried to include to same file into it self.

Hope someone can help!

Too less information to help....
- What is the real error message?
- What is the filesystem location for both files?
- Which file did you access in your browser with which uri?

Re: Relative paths using include() - not working

PostPosted: 02. February 2009 00:44
by kevinmack18
I'm a bit confused by that last post on here.... the "No, i don't have a PHP file with the name "BLAH BLAH" and have never tried to include to same file into it self." post... was this for me? or for someone else? -- Anyway, it was confusing.

"BLAH BLAH" is just a filler for any file in the server's directory.


Is include_path = ".;C:\xampp2\php\pear\" turned off by default? If so, I will give this a try - I will let you know if this works.

Did you have this issue yourself?

Re: Relative paths using include() - not working

PostPosted: 02. February 2009 00:56
by Izzy
kevinmack18 wrote:Is include_path = ".;C:\xampp2\php\pear\" turned off by default? If so, I will give this a try - I will let you know if this works.
Not turned off by default as can be seen in the code frame above.

The default settings in the php.ini file should work for most correctly coded php scripts.
See this Forum Search

See this Google search for definitions of relative and absolute paths.
Or this Google search for relative paths in php.

The C:\xampp\htdocs\xampp folder contains many examples of includes and all working if you test them.

kevinmack18 wrote:Did you have this issue yourself?
If you mean me, no. Never have I had your include issue with any of hundreds of php scripts in many different versions of XAMPP.

Re: Relative paths using include() - not working

PostPosted: 03. February 2009 22:35
by kevinmack18
Well, I still can't seem to get it to work. This works on my production server host but not with Xampp locally.

hmm. I keep trying to dig and find a solution - besides replacing ALL MY PATHS to the full "c:/"

Re: Relative paths using include() - not working

PostPosted: 03. February 2009 22:43
by Izzy
Code: Select all
Warning: include("BLAH BLAH") [function.include]: failed to open stream: No such file or directory in "BLAH BLAH"
Warning: include() [function.include]: Failed opening '"BLAH BLAH"' for inclusion (include_path='.;C:\xampp\php\pear\') in "BLAH BLAH"
Can you replace the BLAH BLAH with the actual code, as it is hard to try and imagine what path you are having trouble with and also as much detail as possible as it is impossible to see what you see and what you do from here.

Re: Relative paths using include() - not working

PostPosted: 04. February 2009 00:30
by kevinmack18
Code: Select all
Warning: include() [function.include]: Failed opening '../setup/edit/sets.php' for inclusion (include_path='.;C:\xampp\php\pear\') in C:\xampp\htdocs\Sites\Working\htdocs\dir\app\call.php on line 3
Warning: include(../setup/edit/sets.php) [function.include]: failed to open stream: No such file or directory in C:\xampp\htdocs\Sites\Working\htdocs\dir\setup\templates.php on line 3


Here are two separate warnings. The odd thing is that the full path to the php-file is the actual location of the file on my computer ("C:\xampp\htdocs\Sites\Working\htdocs\dir\app\call.php" — exists).

Re: Relative paths using include() - not working

PostPosted: 07. February 2009 01:56
by kevinmack18
Any new thoughts on this? I'm still having this issue.

include() is working (for the most part) - but it's really only on simple cases. I checked to make sure "safe mode" was off - and it is.

hmm

Re: Relative paths using include() - not working

PostPosted: 07. February 2009 03:30
by kevinmack18
Basically, I have resolved this just by changing code a couple of lines of code. The code did not have errors - it worked perfectly on my Mac, Linux, and my (paid) server. I think that Xampp just might be sensitive, there must be something in the .ini that is causing it to do that. For now, I don't care -- but I'd like to solve it someday.

Thanks for all your help everyone :)

Re: Relative paths using include() - not working

PostPosted: 07. February 2009 03:41
by Izzy
Thanks for posting back but it would have been nice of you to let us know how you resolved your code issue so as to round off the topic with a result so others searching may also benefit.
Thanks.