includes linking to other files, help with relatives

includes linking to other files, help with relatives

am 07.12.2009 06:47:30 von Allen McCabe

--00504502b22e4745df047a1cfeff
Content-Type: text/plain; charset=ISO-8859-1

I am creating a database connection path that check for a session variable
to get the username, password, dbname, etc., but if the session has not been
set yet, I need my script to get those values from another file
(KEY.txt) where they are saved. I want to access this class from two
directories, and this text file (KEY.txt) is in a directory above both. Like
this:

root: folder1 - folder2

folder1: KEY.txt

folder2: index.php - database.php - folder3

folder3: index.php

I need to use database.php in both index files, but database.php references
KEY.txt. So my question is, do I have to check which directory the calling
script is in (ie. which index.php file is using database.php) and add the
according up directory references, or do I need to use some kind of
$_SERVER[DOCUMENT_ROOT]
thing?

Any help would be appreciated!

--00504502b22e4745df047a1cfeff--

Re: includes linking to other files, help with relatives

am 07.12.2009 07:16:23 von Midhun Girish

--00504502f623c2292b047a1d6661
Content-Type: text/plain; charset=ISO-8859-1

Hello Allen McCabe,

it doesnt matter from which folder you call the database.php file..... only
thing u must take care is to use correct path in the database.php file so
that key.txt is accurately referenced..... if you are still having problems,
use absolute paths instead of relative path...hers a reference
http://www.ibdhost.com/help/path/.... GL...


Midhun Girish


On Mon, Dec 7, 2009 at 11:17 AM, Allen McCabe wrote:

> I am creating a database connection path that check for a session variable
> to get the username, password, dbname, etc., but if the session has not
> been
> set yet, I need my script to get those values from another file
> (KEY.txt) where they are saved. I want to access this class from two
> directories, and this text file (KEY.txt) is in a directory above both.
> Like
> this:
>
> root: folder1 - folder2
>
> folder1: KEY.txt
>
> folder2: index.php - database.php - folder3
>
> folder3: index.php
>
> I need to use database.php in both index files, but database.php references
> KEY.txt. So my question is, do I have to check which directory the calling
> script is in (ie. which index.php file is using database.php) and add the
> according up directory references, or do I need to use some kind of
> $_SERVER[DOCUMENT_ROOT]
> thing?
>
> Any help would be appreciated!
>

--00504502f623c2292b047a1d6661--