Jump to content

Accessing Connection file in different files


cutebird75

Recommended Posts

Hello every body!

I am not very genious in programming. I am working on a online system.

I have my connection file in "home/config/connection.php" directory.

Now I am accessing this file through include ('../connection.php') on first level and include('../../connection.php') on second level. I have to mention all this in each file.

but the problem is that if I have to change my directory structure or relocate files to a new place then I will have to change path manually in all files. if there is any specific solution to solve this problem.please tell me about it in datail.

Thanks alot.

You can make yourself a config file, where you make a variable for every path to your files. for example, yuo make a config.php with $connpath = 'home/config/connection.php';

$someotherfile = 'someotherpath';

 

then you just include this config file to the files and use include $connpath; and all you have to change is the config file. I'd do it that way, if someone has a better solution, please do tell it :P

 

-NikkiLoveGod.

but the problem is still there. when i will include config file to all other files it would also require relative path

to the config file. and i will have to manually tell the path.

this is my original problem.please keep in mind this point.

Hello every body!

I am not very genious in programming. I am working on a online system.

I have my connection file in "home/config/connection.php" directory.

Now I am accessing this file through include ('../connection.php') on first level and include('../../connection.php') on second level. I have to mention all this in each file.

but the problem is that if I have to change my directory structure or relocate files to a new place then I will have to change path manually in all files. if there is any specific solution to solve this problem.please tell me about it in datail.

Thanks alot.

 

Please tell me in detail

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.