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?
Are you running
includes/connectvars.phpdirectly or is it included by other file?I think you are running
index.phpand 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: