doubledee Posted April 22, 2011 Share Posted April 22, 2011 In NetBeans - in what I think is the Web Root - I have... config.inc.php secure/checkout.php In "checkout.php", when I use this code it works... <?php require_once "../config.inc.php"; ?> but when I try to use an Absolute Path, it errors out... <?php require_once "/config.inc.php"; ?> I thought "/" moved you up to the Web Root and then you drill down from there? So the second example should also work in my mind?! What is wrong? Debbie Quote Link to comment https://forums.phpfreaks.com/topic/234478-problem-with-path/ Share on other sites More sharing options...
kenrbnsn Posted April 22, 2011 Share Posted April 22, 2011 Using a slash at the start of a path like that, say to start at the root of the whole file system, which is not what you want. You want to do something like <?php require_once $_SERVER['DOCUMENT_ROOT'] . '/config.inc.php'; ?> If your file is in the webroot. Ken Quote Link to comment https://forums.phpfreaks.com/topic/234478-problem-with-path/#findComment-1205071 Share on other sites More sharing options...
doubledee Posted April 22, 2011 Author Share Posted April 22, 2011 Ken, I could really use some more help on this topic. (Now that my website is more than one page and has lots of includes, I've got a real disaster here.) This all started when I broke up my home page of which most of the code reappears in other pages. So I created a series of includes like... header.inc.php left_col.inc.php right_col.inc.php footer.inc.php The problem is that files from different directory locations all need a "header.inc.php" which is what brought me to a grinding halt today! Here is a sample of what I have... 00_MyWebsite Source Files components body_header.inc.php body_footer.inc.php secure checkout.php images my_logo.png index.php product_details.php Here is where I need help... In my web root (locally), I have... "index.php" which includes "body_header.inc.php" which has an img link to "images/my_logo.png" But then I also have "secure/checkout.php" includes "body_header.inc.php" which has an img link to "images/my_logo.png". When that happens, I have a major issue!! Things are further complicated by the fact that my "Web Root" is different in NetBeans than on my WebHost... (I don't have the know-how to do anything on my server, so for now I'm looking for an easier way to make my includes behave and easily transition from my Dev Laptop to my Live Web Host.) Please help!!! Debbie Quote Link to comment https://forums.phpfreaks.com/topic/234478-problem-with-path/#findComment-1205079 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.