I am trying to require my "library" files from php files in different folders, but it gives errors when trying to access them from a subfolder. For example I have such a directory:
+ home
- file1.php
++ subfolder
- file2.php
++ libraries
- code_generator.php
- database_library.php
code_generator.php also depends on the other library:
(LINE 25) require_once(realpath("./libraries/database_library.php"));
//this works fine when called from file1.php, but not from file2.php
I try to call code_generator from ./subfolder/file2.php like:
chmod("../libraries/codegenerator.php", 0777); // for the error at the end of this question
require_once("../libraries/code_generator.php");
When I run file2.php, it yields 2 errors:
**Warning**: require_once(C:\xampp\htdocs\home\subfolder): failed to open stream: Permission denied in C:\xampp\htdocs\home\libraries\code_generator.php on line 25
**Fatal error**: require_once(): Failed opening required '' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\home\libraries\code_generator.php on line 25
*line 25 is require_once(realpath("./libraries/database_library.php"));