Jump to content

Php Include Root


kensbeijing

Recommended Posts

Iv read everywhere about people trying to use include and directing it to the root folder. But I stil don't understand how you do it.

include $_SERVER['DOCUMENT_ROOT']."modules/page.php"

Doesn't work, I used the phpinfo() function and it gave me path: /usr/local/bin:/usr/bin:/bin How do I use that to find the root folder?

Link to comment
Share on other sites

Do you mean the document root or the system root? The former you can access with "/"...

Link to comment
Share on other sites

If you're trying $_SERVER['HTTP_HOST'] . "modules/page.php" , you're missing the slash between the root and "modules." But as Synook suggested, the slash is probably ALL you need anyway. Have you tried: "/modules/page.php"?

Link to comment
Share on other sites

<rant>For Gawd sakes, don't make it hard on us trying to help you...Here is just another example of failing to post a link to a Demo page.It is really starting to tick me off when people request help and fail to provide sufficient information.POST A LINK! if you want help...</rant>

Link to comment
Share on other sites

Helloi have the same probem.I want to include a file in from the root directory with name config.php into my file functions/functions_users.php but nothing of the above which you write are working.I am trying the following commandcontent of function_users.php

<?phpinclude $_SERVER['HTTP_HOST'].'/~kokeroulis/config.php';?>

Link to comment
Share on other sites

<rant>For Gawd sakes, don't make it hard on us trying to help you...Here is just another example of failing to post a link to a Demo page.It is really starting to tick me off when people request help and fail to provide sufficient information.POST A LINK! if you want help...</rant>
Sorry I can't post the link man, the site is still under development and I don't want anyone to access it. I think I know why, my host doesn't allow this, I'll have to buy a domain name first. Thanks anyway.
Link to comment
Share on other sites

You don't use $_SERVER['HTTP_HOST'] to include files. $_SERVER['HTTP_HOST'] contains the host header that the browser asked for. You don't include based on the host.Instead of trying to guess about what the correct thing is to use, why don't you people just look it up? There's a list of everything usually in the $_SERVER array here:http://www.php.net/manual/en/reserved.variables.server.phpYou can also use a phpinfo page to look at all server and environment variables:

<?phpphpinfo();?>

You can also just print the $_SERVER array:

<pre><?phpprint_r($_SERVER);?></pre>

All 3 of those are a better solution to this problem than guessing what the correct answer is. I don't understand how anyone expects to get any work done by guessing, when all of the answers are right there in front of you. If you have your web server installed in c:\inetpub\wwwroot\, then open up phpinfo and look for where c:\inetpub\wwwroot\ is defined.I could just tell you what the answer is, but you aren't going to learn anything from that. I found my path in 3 different places in the $_SERVER array.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...