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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

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.