PDA

View Full Version : Replace $DOCUMENT_ROOT so it reads from a subfolder instead from main folder


caver911
04-30-2007, 02:31 PM
I have this coding:

include($DOCUMENT_ROOT . '/head.php'); ?>

I understand that this read the files right from the main directory. I want it to read right from a subfolder since I moved the site. Anyone who have any idea of a codeline that replace the ($DOCUMENT_ROOT . '/head.php') so it will read the file right from the subfolder.

I have tried replace /head.php with subfoldername/head.php. It didn't work. I think the code $DOCUMENT_ROOT have to be replaced with a other code.



I am new in php and just have to ask:)

bustamelon
04-30-2007, 02:43 PM
I have tried replace /head.php with subfoldername/head.php. It didn't work. I think the code $DOCUMENT_ROOT have to be replaced with a other code.


replace '$DOCUMENT_ROOT/head.php' with '$DOCUMENT_ROOT/subfoldername/head.php

The difference being the slash in front of subfoldername.

You might need to erplace $DOCUMENT_ROOT with the full var name if REGISTER_GLOBALS is off (as it should be): $_SERVER['DOCUMENT_ROOT']

Or you can try using $_SERVER['SCRIPT_FILENAME']

More here:

http://www.php.net/reserved.variables

caver911
04-30-2007, 07:16 PM
I can't get the code right.

The existing code are like this:

<?php

include($DOCUMENT_ROOT . '/head.php'); ?>

Could you please give me some different codings of the examples you made. this so I just can paste it in. The file head.php are in a subfolder called 10d.dk.

appreciate your help :)

bustamelon
04-30-2007, 08:49 PM
Try this:

<?php
include( $_SERVER['DOCUMENT_ROOT'] . '/10d.dk/head.php' );
?>

caver911
04-30-2007, 10:26 PM
Thanks, I will try:)

caver911
05-01-2007, 10:54 AM
I have now tried to change the code couple of times. It will not work. When I open the webpage I get this error pages, no matter which code I use:

Warning: main(/home/langsholt/studweb.dreamhosters.com/head.php) [function.main]: failed to open stream: No such file or directory in /home/.perlie/langsholt/studweb.dreamhosters.com/10d.dk/1index.php on line 8

Warning: main(/home/langsholt/studweb.dreamhosters.com/head.php) [function.main]: failed to open stream: No such file or directory in /home/.perlie/langsholt/studweb.dreamhosters.com/10d.dk/1index.php on line 8

Is there something with set up on the server.I think it is a subdomain webhosting. Since I just have pasted the files from the old to the new maybe the path /home/.perlie/langsholt/studweb.dreamhosters.com/10d.dk/1index.php must be changed. You also mentioned something about the global settings, how do change them if it is that of course.

I really don't now what to do......:eek:

bustamelon
05-03-2007, 03:34 AM
show me the code you have on and around line 8

bustamelon
05-11-2007, 04:19 PM
...or not.