BuckeyeTheDog Posted July 13, 2008 Share Posted July 13, 2008 Hello all, 1) Can I set a subdirectory path for an includes file?? As in, when my main php file is on the root can I "include" my server login file from a subdirectory? If so, currently I'm not having luck doing it... Here's a sample... include("/public_html/phptest/AbConnect.php"); in which public_html is my ftp webserver directly, phptest is a subfolder and AbConnect.php is the file with the login info. If I can do this, how do I do it? Or do I need the included file in the same directory? 2) When/if I have PHP and HTML files in a subdirectory and you want to have an "includes" file, do you just place it in that same subdirectory, or can you/ how would you reference a different subdirectory- or go up the path to the root??? Thanks for your help... Link to comment https://forums.phpfreaks.com/topic/114537-solved-includes-path/ Share on other sites More sharing options...
tjmbc Posted July 13, 2008 Share Posted July 13, 2008 1) Try: include("public_html/phptest/AbConnect.php"); Instead of: include("/public_html/phptest/AbConnect.php") 2) To go up a dirctory use ../ so if you were in the "phptest" directory and wanted to go up to the "public_html" directory you would type ../newDirectory . if you are down two directories from root and want to go back to root simply type "../../newDirectory". You can put include files anywhere, just make sure you call them with the correct path. Use "require" instead of "include" as a way of testing to see if the included file is found. If you use require, the page won't load at all and you'll know that the page you wanted to include wasn't found. Link to comment https://forums.phpfreaks.com/topic/114537-solved-includes-path/#findComment-588997 Share on other sites More sharing options...
BuckeyeTheDog Posted July 14, 2008 Author Share Posted July 14, 2008 Thanks, tjmbc. Your answer worked fine- as a matter of fact, it pointed out that I had a deeper path issue that was the culprit... It's now fixed and good to go... Link to comment https://forums.phpfreaks.com/topic/114537-solved-includes-path/#findComment-589206 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.