bɪˈɡɪnə
bɪˈɡɪnə

Reputation: 1085

Defining the correct include path

I am facing a include path error. In a file config.php I am including include ("./inc/logged_in.php" ); which (logged_in.php) further includes include ("./include/connect.php" ); but I get a error saying:

failed to open stream: No such file or directory in C:\xampp\htdocs\demo\fileman\filemanager\config\config.php

Now this error may be because config.php and logged_in.php are in different subfolders and my inclusion path is incorrect. I tried using include ("../../inc/logged_in.php" ); now no error for logged_in.php but error for connect.php:

include(./inc/connect.php): failed to open stream: No such file or directory in C:\xampp\htdocs\demo\inc\logged_in.php

My structure for config.php is:

// root

// |- demo

// | |- fileman

// | | |- filemanager

// | | | |- config

// | | | | |- config.php

My structure for connect.php and logged_in.php is:

// root

// |- demo

// | |- inc

// | | |- connect.php

// | | |- logged_in.php

Upvotes: 0

Views: 79

Answers (1)

MatureBanana
MatureBanana

Reputation: 112

Check it:

/demo/fileman/filemanager/config/config.php

include('../../../inc/logged_in.php');

/demo/inc/logged_in.php

include('connect.php');

Upvotes: 1

Related Questions