Jump to content

PHP includes fine in one place but has error when moved under folders?


minkbooks

Recommended Posts

Hi there
I have just started playing around with PHP includes and have tested it.
When I do it under something like my homepage, its fine. But when I start to create folders and place it under there, an error message keeps coming.
For example.. if I place <? include("/includes/foot.php") ?> in index.php it works fine.
If I create a folder, then copy and paste the exact some thing on a doc and save it under this new folder (so now its something like /about/index.php), an error comes up about something like not being able to open the stream or something.

I'm really sorry if this question has already been asked, but I dont really know what the term is so couldnt do a search.
Thanks in advance.
Kind regards
Link to comment
Share on other sites

take a little time studying the manual entry for include(). it doesn't take absolute paths very well. if you're looking to include a file from different locations, you really ought to try and declare a relative path based on the current directory. so:
[code]
<?php
// if you are trying to include from your root folder:
include("./includes/foot.php");

// if you are trying to include from /about/index.php:
include("../includes/foot.php");
?>
[/code]

hope this helps
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.