Reputation: 2492
I not sure what's going on..maybe I missed something simple.
In my connectvars.php file, I connect to the database using the variables in my config.php folder. Here's the hierarchy:
admin(folder)
config.php
includes(folder)
connectvars.php
index.php
I want to get information from config.php to use in connectvars.php, so I use:
require_once("../admin/config.php");
But everytime I do this I get Warning: require_once(../admin/config.php) [function.require-once]: failed to open stream: No such file or directory in /home/a8879415/public_html/includes/connectvars.php on line 2
BUT when I type: require_once("admin/config.php");
, it works.
I thought I had to go up a level, then go down to admin, then get config.php. So how come I just need to go into the admin folder then get config.php?
Upvotes: 0
Views: 518
Reputation: 29482
Are you running includes/connectvars.php
directly or is it included by other file?
I think you are running index.php
and every files are included relatively to it's path.
If you want to use relative path to other files, it can be done like that:
require_once( dirname(__FILE__) . '/../admin/config.php' );
Upvotes: 2
Reputation: 798884
They run in the context of the main script, so file references should originate from the main script's directory.
Upvotes: 0