Welcome to the Treehouse Community
Looking to learn something new?
Tony Mikel10,661 Points
Root-relative path not working from receipt directory
<?php echo $_SERVER["DOCUMENT_ROOT"] . "/shirts4mike/"; ?> <?php
//require_once(); $pageTitle = "Thank you for your order!"; $section = "none"; include("/shirts4mike/inc/header.php"); ?> <div class="section page"> <div class="wrapper"> <h1>Thank You!</h1> <p>Thank you for your payment. Your transaction has been completed, and a receipt for your purchase has been emailed to you. You may log into your account at <a href="http://www.paypal.com/us">www.paypal.com/us</a> to view details of this transaction.</p> <p>Need another shirt already? Visit the <a href="../shirts.php">Shirts Listing</a> page again.</p> </div> </div> <?php include("shirts4mike/inc/footer.php"); ?>
I get the following:
Warning: include(/shirts4mike/inc/header.php): failed to open stream:
If I understand root-relative correctly, that warning means, it's looking in my htdocs directory -> shirts4mike -> inc ->header.php..
Is that correct?
Lin Lu29,171 Points
I think there's the first forward slash shouldn't be there.
Just like how you include the "foot.php" at the last line of your code, you should include the header file like this:
include("shirts4mike/inc/header.php");, simply remove the first forward slash from your code.