I want to include a file in an included file.
I have a file named acp.php in the directory Pages/cms/src/acp.
In this file I included the file connect_get_data.php in the directory Pages/cms/src/acp/tools, which is to print the database output for the requested page.
In this file I included the Database connection file which is named connection.php in the directory Pages/cms/src/tools.
Here are my include statemants:
acp.php - include("./tools/connect_get_data.php");
connect_get_data.php - include("../../tools/connection.php");
and here is the Error it caused:
<br />
<b>Warning</b>:
include(../../tools/connection.php): failed to open stream: No such file or directory in <b>C:\xampp\htdocs\Pages\cms\src\tools\connect_get_data.php</b> on line <b>2</b><br />
<br />
<b>Warning</b>:
include(): Failed opening '../../tools/connection.php' for inclusion (include_path='C:\xampp\php\PEAR') in <b>C:\xampp\htdocs\Pages\cms\src\tools\connect_get_data.php</b> on line <b>2</b><br />
<br />
<b>Notice</b>:
Undefined variable: db in <b>C:\xampp\htdocs\Pages\cms\src\tools\connect_get_data.php</b> on line <b>4</b><br />
<br />
<b>Warning</b>:
mysqli_query() expects parameter 1 to be mysqli, null given in <b>C:\xampp\htdocs\Pages\cms\src\tools\connect_get_data.php</b> on line <b>4</b><br />
<br />
<b>Warning</b>:
mysqli_fetch_object() expects parameter 1 to be mysqli_result, null given in <b>C:\xampp\htdocs\Pages\cms\src\tools\connect_get_data.php</b> on line <b>5</b><br />
<br />
<b>Notice</b>:
Trying to get property 'Content' of non-object in <b>C:\xampp\htdocs\Pages\cms\src\tools\connect_get_data.php</b> on line <b>6</b><br />
<br />
<b>Notice</b>:
Undefined variable: db in <b>C:\xampp\htdocs\Pages\cms\src\tools\connect_get_data.php</b> on line <b>7</b><br />
<br />
<b>Warning</b>:
mysqli_close() expects parameter 1 to be mysqli, null given in <b>C:\xampp\htdocs\Pages\cms\src\tools\connect_get_data.php</b> on line <b>7</b><br />
But if I open the connect_get_data.php in my browser it works fine...
I hope some one her can help me with my issue.
$_SERVER['DOCUMENT_ROOT']and use the path from there. By just using dots, it will attempt to access the file relative to the current URL path.