Jump to content

Problems with php includes from diff file paths. Need help


Lexicon

Recommended Posts

my directory on my mamp server looks like this;

 

root/website/index.php

 

I also have some files in a folder like this

 

root/website/pages/files.php

 

My include code is this

include("functions.php");

 

When I try to include a file from the 'website' folder from a page in the 'pages' folder. It gives me errors that look like this.

Warning: include(functions.php) [function.include]: failed to open stream: No such file or directory in /website/pages/contact.php on line 2

Warning: include() [function.include]: Failed opening 'functions.php' for inclusion (include_path='.:/Applications/MAMP/bin/php5.3/lib/php') in /Applications/MAMP/htdocs/website/pages/contact.php on line 2

 

That's what it looks like.. I can't get it working.

 

Link to comment
Share on other sites

that worked. but now when i click on the website logo that is supposed to bring me to

 

root/website/index.php

 

it brings me to

 

root/website/pages/index.php instead... and gives me 404 invalid page or whatever

 

the header code I have is just a link that brings me to /index.php

Link to comment
Share on other sites

$_SERVER['DOCUMENT_ROOT'] returns the full file system path to the root of the current vhost. This path means nothing to a browser which is only interested in the path *after* the document root. The rest is unreachable from the web.

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.