Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Enhancing a Simple PHP Application Cleaning URLs with Subfolders Introducing Constants

Diego Villaseñor
Diego Villaseñor
12,615 Points

Trouble with ROOT_PATH

Tried to follow the lesson but the header is not being loaded. I should say that I have been doing Wordprss development, and so, I changed the document root folder to another in MAMP's preferences. The folder I have been working is called Wordpress.

Here's my code for the config.php file:

    define("BASE_URL","/NonWp/PHP/shirts4mike%20pt.1/");
    define("ROOT_PATH",$_SERVER["DOCUMENT_ROOT"] . "/NonWp/PHP/shirts4mike%20pt.1/");

And my code for the index.php in the "receipt" folder:

<?php

require_once("../inc/config.php");

$pageTitle = "Thank you for your order!";
$section = "none";
include(ROOT_PATH . "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= "<?php echo BASE_URL;?>shirts.php">Shirts Listing</a> page again.</p>

            <?php echo ROOT_PATH . "inc/header.php";?>


        </div>

    </div>

<?php include(ROOT_PATH . "inc/footer.php"); ?>

As you can see, almost at the end I am echoing this code:

<?php echo ROOT_PATH . "inc/header.php";?>

and it looks as follows: /Users/user/Documents/Webpages/Wordpress/NonWp/PHP/shirts4mike%20pt.1/inc/header.php

That is the path to the file, nevertheless it is not being loaded.

Please help, been trying to solve this for about an two hours with no luck.

Thanks in advance.

3 Answers

Jesus Menera
Jesus Menera
17,304 Points

PHP <?php include(ROOT_PATH . "inc/header.php"); ?>

Diego Villaseñor
Diego Villaseñor
12,615 Points

Jesus, that's what I have got, isn't it?

Jesus Menera
Jesus Menera
17,304 Points

what is the error message you are getting? also closed the syntax like this: PHP <?php require_once('../inc/config.php'); ?> and then start a new one PHP <?php include (ROOT_PATH . 'inc/header.php'); ?> and I see you use double "" use the single ' , let me know if that works.

Jesus Menera
Jesus Menera
17,304 Points

<?php include(ROOT_PATH . 'inc/header.php'); ?>