I am creating a browser/text-based game. In order to organize the files, I broke them down into different folders
Game
Server //DB Connection Files
Styles //CSS Files
Structure //Any Template files for the viewable pages (menu bars, etc that I don't want to copy in each viewable .php**
Scripts //JS Files
Location Folders // Like 'Work' or 'Crime' - the menu options
If I'm in say localhost/game/work/work.php and want to access the database, I would have to use
include "../../server/dbc.php";
I have tried
$root = dirname(__file__);
in my localhost/game folder before, but it started giving me an error - "failed to open stream: no suitable wrapper could be found" which is because it's using a full file location and you apparently can't do that.
Is there an easier way to make it so I can access my DB from anywhere regardless of hierarchy in the folders?
Thank you in advance!