I'm building the basic framework for my website and I have a config.php file stored in a scr directory. Additionally, this directory has a folder called php where I store a file called sidebar.php
Basically, the config.php file will hold my database configuration variables and is also the only file called by every page. I wish to include php/sidebar.php in this file so any variables I create in sidebar.php can be used on all pages.
However, I also want sidebar.php to have access to the database configuration variables. So these two files will effectively be including each other.
The include from config to sidebar is:
include 'php/sidebar.php';
From sidebar to config is:
include '../config.php';
However, the above statement (sidebar to config) yields the below error message:
Warning: include(../config.php) [function.include]: failed to open stream:
No such file or directory in C:\xampp\website\scr\php\sidebar.php on line 3
Am I going about this all wrong cross-linking the two files or is there a decent reason why it's not working
include_once<?php include_once('config.php'); ?>as the top line (or before any other includes), and never worry about that file again.