I'm having very confusing problems with a basic php include.
I'm currently working on a version 2 of a website, so my index.php is located in
www.mywebsite.co.uk/v2/index.php
I have a database config file located inside
www.mywebsite.co.uk/v2/assets/database.php
I have a form action located inside
www.mywebsite.co.uk/v2/assets/actions/action.php
I need to include my database.php file inside my action.php file, but I cant seem to find the right include path.
I've tried
include "database.php";
include "assets/database.php";
include "../assets/database.php";
include "../../assets/database.php";
include "../database.php";
include "../../database.php";
include "../../../database.php";
include "../../../assets/database.php";
I've even started using
include(dirname(__FILE__)."../database.php");
But no matter what i try, the include file cannot be found, and my action page returns a 500 server error.
What am I doing wrong?
UPDATE
I'm having the weirdest issue, and I really cant figure out whats going on.
I am including all my files normally, and they all work great, but as soon as it comes to a form action file, include just refuses to work.
I'm including a database OOP file in my header across the site, and it works great. I then have a form which submits using POST to an action file, and as soon as I include the database in my action file, it refuses to work. It will only work if I use
dirname(__FILE__)."my/path"
The location of the action file is in the same folder as all my other files which are using the include function, so the path is definitely correct, but whenever i try to include on my action file I get a 500 server error unless i use the dirname(FILE)."my/path" method.
Any ideas?
UPDATE 2
For some reason I have to use a different include path for 2 different files both in the same location.
For example database.php, home-slider.php and includes.php are all in the same directory. If I want database.php to access the includes file I can use
include "assets/includes.php";
But if i want to access the includes file using the home-slider.php page I have to use
include "../assets/includes.php";
Even though they are all in the same directory?