PHP includes problem

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

PHP includes problem

Postby oldguy » 19. March 2006 09:03

I have been using phpdev on my Win XP system at home for a couple of years as a development system. But it is occasionaly a little "flakey" so I decided to try Xampp (1.5.1). I Installed it and it seems to work fine except one thing...I can't get my php includes to work. I get the following:

Warning: include() [function.include]: Failed opening '/includes/docHead.php' for inclusion (include_path='.;\xampp\php\pear\;\aaa') in E:\aaa\index.php on line 1

FYI: To match my existing system, after installing xampp I changed http.conf:
DocumentRoot "/aaa"
<Directory "/aaa">

and php.ini (the one in apache/bin): include_path = ".;\xampp\php\pear\;\aaa"

This is how the includes look in my php files: <?php include ($DOCUMENT_ROOT."/includes/docHead.php"); ?>

I do of course have a \aaa\includes directory with all the include files in it. If I strip the preceeding "/" from the include, it works. But the preceeding slash is necessary because the include won't work on the production server (commercial web host) without it.

Please note that phpdev had no problem with the preceeding slash. I can't figure out why it is causing a problem under Xampp.

Anyone have any ideas about a solution...other than remove the preceeding slash from the include statement? I
oldguy
 
Posts: 10
Joined: 19. March 2006 08:39
Location: Portland, Oregon USA

Postby Wiedmann » 19. March 2006 11:17

This is how the includes look in my php files: <?php include ($DOCUMENT_ROOT."/includes/docHead.php"); ?>

There is no variable $DOCUMENT_ROOT. Please consult phpinfo() or the PHP-manual:
Code: Select all
<?php include $_SERVER['DOCUMENT_ROOT'].'/includes/docHead.php'; ?>
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby oldguy » 19. March 2006 13:40

Thank you Wiedmann. I changed the include statements on one page and ran a test on my PC under xampp and on the production server. Obviously it worked fine.

Funny thing though, the syntax I was using has worked fine on both the production server and on my PC under phpdev for 2 years or so. It's been so long I can't remember where I got that syntax from nor do I know why it works on both systems, but it does. Image
oldguy
 
Posts: 10
Joined: 19. March 2006 08:39
Location: Portland, Oregon USA

Postby Wiedmann » 19. March 2006 13:50

Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby oldguy » 19. March 2006 14:05

Well that's proof of the old adage that for every quandary there is an answer. :)

Thanks again. I guess we'll mark this problem solved. If I keep xampp, I will definitely make a donation. It's nice to know there is friendly support.
oldguy
 
Posts: 10
Joined: 19. March 2006 08:39
Location: Portland, Oregon USA


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 138 guests