So, I have been trying to use the XAMPP server as part of my school project, but I am getting an internal server error when I try to require a particular php file from another directory, here is what I mean:
I have this directory heirarchy:
and in my about.php
file I am trying to require the about.view.php
but I get an internal server error when I do that. Here is my about.php
content:
Why am I getting this error? and I tried every possible thing I can think of. Please, help me out.
Your about.php
file is located in the controllers
folder. You want to include the views/about.view.php
file according to your code. That means starting from about.php
, you want to include the controller/views/about.view.php
file. This is incorrect because your views folder is not inside the controllers
folder. It is located outside of it.
The correct approach is to go up one level by using ../
. This means starting from your interhub folder, the request should be interpreted as ../views/about.view.php
. So, it starts from the controllers
folder, then goes back one level to the interhub
folder with ../
, and then goes into the views
folder with /views
. After these steps, it will find the about.view.php
file and your code will run correctly.
require_once "../views/about.view.php";
Okay, this file reference is fixed, check! If you receive further 500 error codes, it's definitely not because of this, but rather due to an error in your PHP code. You can output the errors to the screen or view them in the Apache error.log file.
// Show error message instead of "Error 500" blank page.
ini_set('display_errors', 1);
error_reporting(E_ALL);
Warning! Use it exclusively for home development purposes!
In live code, this poses a security vulnerability!