Page 1 of 1

PHP includes problem

PostPosted: 19. March 2006 09:03
by oldguy
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

PostPosted: 19. March 2006 11:17
by Wiedmann
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'; ?>

PostPosted: 19. March 2006 13:40
by oldguy
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

PostPosted: 19. March 2006 13:50
by Wiedmann

PostPosted: 19. March 2006 14:05
by oldguy
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.