ev5unleash1 Posted July 23, 2012 Share Posted July 23, 2012 Hi all, Currently, I'm creating an application with a constant variable that I wish to use throughout the site. I can easily use the include('thisfile.php'); but when I try to include the file from a lower directory like this include ('thisfolder/thisfile.php'); it doesn't seem to work. I can include and open other files like .txt documents but jut not .PHP files. I've looked through the PHP settings but I cannot see any setting that would remotely relate to the problem I am having. Any advice would be awesome at this point, I'm stumped. Quote Link to comment https://forums.phpfreaks.com/topic/266136-issue-with-include-php-file-in-another-folder/ Share on other sites More sharing options...
xyph Posted July 23, 2012 Share Posted July 23, 2012 I've never seen that behaviour. What specific error are you getting? Quote Link to comment https://forums.phpfreaks.com/topic/266136-issue-with-include-php-file-in-another-folder/#findComment-1363809 Share on other sites More sharing options...
ManiacDan Posted July 23, 2012 Share Posted July 23, 2012 If the directory is actually LOWER, that means it's DEEPER into the tree, and won't work. Always use absolute paths starting from $_SERVER['DOCUMENT_ROOT'] so you don't have this issue. Quote Link to comment https://forums.phpfreaks.com/topic/266136-issue-with-include-php-file-in-another-folder/#findComment-1363820 Share on other sites More sharing options...
xyph Posted July 23, 2012 Share Posted July 23, 2012 If the directory is actually LOWER, that means it's DEEPER into the tree, and won't work. Always use absolute paths starting from $_SERVER['DOCUMENT_ROOT'] so you don't have this issue. Depends how you look at the tree. Hierarchical structures go top->bottom or left->right in most UIs. I always find myself clarifying this terminology with colleagues just to be sure. It goes both ways all the time I find. Quote Link to comment https://forums.phpfreaks.com/topic/266136-issue-with-include-php-file-in-another-folder/#findComment-1363823 Share on other sites More sharing options...
ev5unleash1 Posted July 25, 2012 Author Share Posted July 25, 2012 Sorry if I wasn't clear about my directory issue. So far I cannot include any file that isn't in the same directory as the file that is including it. For example: File path "/php/scripts/request.php" cannot include a file from "/php/scripts/morescripts/filetoinclude.php". I clearly remember being able to do this in the past, so why aren't I able to now? I've fiddled around with "allow url include" but it still doesn't follow through. Error I'm getting at the moment: Warning: include(actions/clearverify.php?grade=11th): failed to open stream: No error in C:\wamp\stratus\apps\coursechange\admin\clear.php on line 16 Warning: include(): Failed opening 'actions/clearverify.php?grade=11th' for inclusion (include_path='.;C:\php\pear') in C:\wamp\stratus\apps\coursechange\admin\clear.php on line 16 Before I somehow got Error: The stream is currently unavailable, or something around that... I also can't seem to find any insight anywhere on the internet. Thanks for the swift replies everyone! Quote Link to comment https://forums.phpfreaks.com/topic/266136-issue-with-include-php-file-in-another-folder/#findComment-1364145 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.