472,954 Members | 1,649 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,954 software developers and data experts.

Document root not website root

jpb
Could someone please help me with this.

I want to use PHP in my website; but run into a snag, the recommended
method of calling an include is:
<?php include($_SERVER["DOCUMENT_ROOT"]."/inc/css-gateway.inc"); ?>

when I try
<?php ECHO $_SERVER["DOCUMENT_ROOT"]; ?> the document root is shown as
/usr/local/apache/htdocs/

However the website root is at:
/mnt/home/www/canadian-dream.com/www

How do I redirect $_SERVER["DOCUMENT_ROOT"] to the my website root? Is
there a global variable that can be used? I do not wish to rewrite a lot
of pages if I were to change web host in the future.

from the error logs

[Sat Oct 25 06:32:51 2003] [error] PHP Warning:
main(/usr/local/apache/htdocs/inc/css-gateway.inc): failed to open stream:
No such file or directory in
/mnt/home/www/canadian-dream.com/www/de/immobilien/main.php on line 15
[Sat Oct 25 06:32:51 2003] [error] PHP Warning: main(): Failed opening
'/usr/local/apache/htdocs/inc/css-gateway.inc' for inclusion
(include_path='.:/usr/local/lib/php') in
/mnt/home/www/canadian-dream.com/www/de/immobilien/main.php on line 15
Thanks

Paul
Jul 17 '05 #1
2 50068

"jpb" <jp*@arcor.de> wrote in message
news:pa****************************@arcor.de...
Could someone please help me with this.

I want to use PHP in my website; but run into a snag, the recommended
method of calling an include is:
<?php include($_SERVER["DOCUMENT_ROOT"]."/inc/css-gateway.inc"); ?>

when I try
<?php ECHO $_SERVER["DOCUMENT_ROOT"]; ?> the document root is shown as
/usr/local/apache/htdocs/

However the website root is at:
/mnt/home/www/canadian-dream.com/www

How do I redirect $_SERVER["DOCUMENT_ROOT"] to the my website root? Is
there a global variable that can be used? I do not wish to rewrite a lot
of pages if I were to change web host in the future.

from the error logs

[Sat Oct 25 06:32:51 2003] [error] PHP Warning:
main(/usr/local/apache/htdocs/inc/css-gateway.inc): failed to open stream:
No such file or directory in
/mnt/home/www/canadian-dream.com/www/de/immobilien/main.php on line 15
[Sat Oct 25 06:32:51 2003] [error] PHP Warning: main(): Failed opening
'/usr/local/apache/htdocs/inc/css-gateway.inc' for inclusion
(include_path='.:/usr/local/lib/php') in
/mnt/home/www/canadian-dream.com/www/de/immobilien/main.php on line 15
Thanks

Paul


Have you examined the output of phpinfo();

You have two different paths noted in your log file - One in
/usr/local/apache/htdocs, and the other in /mnt/home/www/canadian-dream.com.
The "/mnt" in one file path leads me to believe you are using NFS, which if
true, is likely to be part of the problem... If you are using Apache, I know
it can serve on an NFS server, however I do know there are some issues that
one must consider when configuring the server - I can't recall what they are
but maybe that gives you a couple of things to work on... an alternative
workaround would be to create a variable that has your "include" directory
hard-coded which you use instead of using "$_SERVER[DOCUMENT_ROOT]" -
therefore whenever you move the script, you only have to change one
variable, but I don't really like that sort of idea.

Hope that gives you some ideas...
Jul 17 '05 #2
jpb
On Sun, 26 Oct 2003 06:11:11 +0000, Randell D. wrote:

"jpb" <jp*@arcor.de> wrote in message
news:pa****************************@arcor.de...
Could someone please help me with this.

I want to use PHP in my website; but run into a snag, the recommended
method of calling an include is:
<?php include($_SERVER["DOCUMENT_ROOT"]."/inc/css-gateway.inc"); ?>

when I try
<?php ECHO $_SERVER["DOCUMENT_ROOT"]; ?> the document root is shown as
/usr/local/apache/htdocs/

However the website root is at:
/mnt/home/www/canadian-dream.com/www

How do I redirect $_SERVER["DOCUMENT_ROOT"] to the my website root? Is
there a global variable that can be used? I do not wish to rewrite a lot
of pages if I were to change web host in the future.

from the error logs

[Sat Oct 25 06:32:51 2003] [error] PHP Warning:
main(/usr/local/apache/htdocs/inc/css-gateway.inc): failed to open
stream: No such file or directory in
/mnt/home/www/canadian-dream.com/www/de/immobilien/main.php on line 15
[Sat Oct 25 06:32:51 2003] [error] PHP Warning: main(): Failed opening
'/usr/local/apache/htdocs/inc/css-gateway.inc' for inclusion
(include_path='.:/usr/local/lib/php') in
/mnt/home/www/canadian-dream.com/www/de/immobilien/main.php on line 15
Thanks

Paul


Have you examined the output of phpinfo();

You have two different paths noted in your log file - One in
/usr/local/apache/htdocs, and the other in
/mnt/home/www/canadian-dream.com. The "/mnt" in one file path leads me to
believe you are using NFS, which if true, is likely to be part of the
problem... If you are using Apache, I know it can serve on an NFS server,
however I do know there are some issues that one must consider when
configuring the server - I can't recall what they are but maybe that gives
you a couple of things to work on... an alternative workaround would be to
create a variable that has your "include" directory hard-coded which you
use instead of using "$_SERVER[DOCUMENT_ROOT]" - therefore whenever you
move the script, you only have to change one variable, but I don't really
like that sort of idea.

Hope that gives you some ideas...

I have a work around, not very elligent but works like a Lada

conf.php

<?php
//CONTENT OF THE FILE
$mydocumentroot=$_SERVER["DOCUMENT_ROOT"];

if($mydocumentroot!="/home/jpb/public_html/www")
{
$mydocumentroot="/mnt/home/www/canadian-dream.com/www";
}
//END OF THE INCLUDED FILE
?>
on webpage <?php include("../../../etc-etc-/inc-php": ?>
then use <?php include($mydocumentroot."bla.inc") ?>

Paul
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Doug | last post by:
I have a website I am trying to develop using PHP and Dreamweaver. I also have a library of PHP code which includes the username and password to get in the database. I would like to put this...
1
by: Andy Fish | last post by:
Hi, I'm using XML DOM in Java and I have a function like this Element makeSomeXml(Document doc) {..} This returns an Element owned by (but not appended to) the specified document. Now,...
2
by: yburtin | last post by:
Hi, I'm currently working on a dotnet web application and here is the problem I have: On my computer (french version of xp pro), I have my webserver installed. Inside one of my webpages, I...
0
by: Michiel | last post by:
Here's the situation: Windows XP SP2 with VS .Net 2003 Web project located on: Windows Server 2003 IIS 6 & Remote Debugging Website with document root pointing to UNC share on: Windows...
0
by: Nata | last post by:
hi all i am trying to store the XML Document object into MS SQL2005 i want to store this as whole not different tables; plz help me regarding this i am trying form last two weeks i asked many...
2
by: news.sbcglobal.net | last post by:
I hope I can explain this well enough to understand. I have a master page that is used by almost all of the pages in my site. On the master page is a table. In one of the cells in this table, I...
10
by: Simon Brooke | last post by:
The DOM API has included public Node importNode(Node,boolean) as a method of the Document interface for a long time. Does anything actually implement it? Xerces 2 is giving me: ...
6
by: mistral | last post by:
what is correct way open a PDF document in new window use hyperlink? I want show images thumbnails linked with PDF files, when click on thumbnail, PDF will be opened in new window. Some of PDF...
2
by: Bobby Edward | last post by:
I have a subdirectory with an aspx page that references a master file located in the root. In the master file template I reference a logo/image that is in <root>/resources... <img alt="logo"...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
1
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.