I am haviing issue in including file in php
`<?php
include "../../db/db_connection.php";`
Error
Warning: include(../../db/db_connection.php): Failed to open stream: No such file or directory in /var/www/html/practice/Blogs/actions/accounts/general.php on line 2
Here is my directories
I try to check it in terminal and the file is opened normally but giving error on the localhost
CodePudding user response:
You need to use DIR, also you have only one level "../"
include __DIR__ . '/../db/db_connection.php';
But it`s better to use require_once for config files
CodePudding user response:
You may check you file location first, include()
and its relatives take filesystem paths, not web paths relative to the document root.
To get the parent directory use ../
include('../db/db_connection.php');
include('../../db/db_connection.php');