Page 1 of 1

PATH Problem

Posted: Mon Apr 21, 2008 6:22 pm
by joseluisxxi1
Ok, what I'm trying to do is :

create a link like this http://www.domain.com/folder1

inside "folder1" I have an index.php with only this code :
<?php include("../file.php"); ?> and that file is calling other files on the root

and I have an error message lie this :

Warning: include(includes/connection.php) [function.include]: failed to open stream: No such file or directory in /Applications/MAMP/htdocs/clint/includes/header.php on line 1


I hope someone understand what I'm trying to do

Thank You

Re: PATH Problem

Posted: Mon Apr 21, 2008 6:53 pm
by aceconcepts
It all depends on where you're calling the file from.

To call the following file: http://www.domain.com/includes/connection.php

from: http://www.domain.com/folder1/index.php

you would write:

Code: Select all

 
include("../includes/connection.php"); // ../ is equivelant to up one level
 

Re: PATH Problem

Posted: Mon Apr 21, 2008 7:17 pm
by joseluisxxi1
yes I can use include("../includes/connection.php")

but what ....if I run a file from the root and I can't use ../includes

how I can tell the paths if the file comes from the root or from a subfolder

Re: PATH Problem

Posted: Mon Apr 21, 2008 7:29 pm
by aceconcepts
Take a look at: http://helicron.net/php/