PATH Problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
joseluisxxi1
Forum Newbie
Posts: 2
Joined: Mon Apr 21, 2008 6:08 pm

PATH Problem

Post 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
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: PATH Problem

Post 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
 
joseluisxxi1
Forum Newbie
Posts: 2
Joined: Mon Apr 21, 2008 6:08 pm

Re: PATH Problem

Post 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
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: PATH Problem

Post by aceconcepts »

Take a look at: http://helicron.net/php/
Post Reply