kensbeijing Posted February 6, 2009 Share Posted February 6, 2009 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 More sharing options...
jlhaslip Posted February 6, 2009 Share Posted February 6, 2009 try $_SERVER['HTTP_HOST'] Link to comment Share on other sites More sharing options...
Synook Posted February 7, 2009 Share Posted February 7, 2009 Do you mean the document root or the system root? The former you can access with "/"... Link to comment Share on other sites More sharing options...
kensbeijing Posted February 7, 2009 Author Share Posted February 7, 2009 Do you mean the document root or the system root? The former you can access with "/"...Well I mean back to the root folder e.g. at www.mysite.com, the first folder where you'd put your index.html. $_SERVER['HTTP_HOST'] doesn't seem to work. Link to comment Share on other sites More sharing options...
jlhaslip Posted February 7, 2009 Share Posted February 7, 2009 echo it out to see what is in there? Link to comment Share on other sites More sharing options...
kensbeijing Posted February 7, 2009 Author Share Posted February 7, 2009 echo it out to see what is in there?That's wierd because it gives me the correct URL of my website, but when I use it, it still says theres no such file. In the error it gives me, it gives the correct url to the file, but some reason it doesnt think so. Link to comment Share on other sites More sharing options...
jeffman Posted February 7, 2009 Share Posted February 7, 2009 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 More sharing options...
jlhaslip Posted February 8, 2009 Share Posted February 8, 2009 <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 More sharing options...
kokeroulis Posted February 8, 2009 Share Posted February 8, 2009 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 More sharing options...
kensbeijing Posted February 8, 2009 Author Share Posted February 8, 2009 <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 More sharing options...
justsomeguy Posted February 9, 2009 Share Posted February 9, 2009 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.