Jump to content

which is the root?


jeff5656

Recommended Posts

Having problems pointing to where files are.

 

Is this the root?:

 

include "../connectdb.php";

 

That file is locate din the root.  If I am already in the root when I include that statment, the file isn't found.  If I use the above code while I am in the subdirectory hello, (root/hello), it works.

 

I use this in every page, so I think I need a way to point to the absolute root, not relative.

 

 

 

Link to comment
Share on other sites

Actually that doesn't work.  The $_SERVER['DOCUMENT_ROOT'] that I get back is not the actual location where my index file is.  I think this link explains why: http://www.helicron.net/php/

Perhaps my host is not using apache (since above only works in apache).

In any case, is there a way to solve this with relative paths?  I thought that if I was in a subdirectory and I want to point to another subdirectory I would point to

 

include "../anotherdirectory/filename.php";

but that doesn't work.

 

Obviously the best solutions would be some way to automatically determine the root directory (regardless of whether the host has apache).  Any ideas?

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.