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
Aaron Lafleur
10,474 PointsShirts4Mike not going well4me
I have spent far too long trying to figure this one out on my own, and I want to get on with my life. Every page on the site works, except for the home page, index.php. Neither the css nor the favicon will load, and none of the links to other pages work. Below is what is revealed viewing page source, and the code I have written while following Randy's course.
<br />
<b>Notice</b>: Use of undefined constant ROOT_PATH - assumed 'ROOT_PATH' in <b>C:\xampp\htdocs\index.php</b> on line <b>4</b><br />
<br />
<b>Warning</b>: include(ROOT_PATHinc/header.php): failed to open stream: No such file or directory in <b>C:\xampp\htdocs\index.php</b> on line <b>4</b><br />
<br />
<b>Warning</b>: include(): Failed opening 'ROOT_PATHinc/header.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in <b>C:\xampp\htdocs\index.php</b> on line <b>4</b><br />
<div class="section banner">
<div class="wrapper">
<img class="hero" src="img/mike-the-frog.png" alt="Mike the Frog says:">
<div class="button">
<a href="<br />
<b>Notice</b>: Use of undefined constant BASE_URL - assumed 'BASE_URL' in <b>C:\xampp\htdocs\index.php</b> on line <b>11</b><br />
BASE_URLshirts.php">
<h2>Hey, I’m Mike!</h2>
<p>Check Out My Shirts</p>
</a>
</div>
</div>
</div>
<div class="section shirts latest">
<div class="wrapper">
<h2>Mike’s Latest Shirts</h2>
<br />
<b>Notice</b>: Use of undefined constant ROOT_PATH - assumed 'ROOT_PATH' in <b>C:\xampp\htdocs\index.php</b> on line <b>26</b><br />
<br />
<b>Warning</b>: include(ROOT_PATHinc/products.php): failed to open stream: No such file or directory in <b>C:\xampp\htdocs\index.php</b> on line <b>26</b><br />
<br />
<b>Warning</b>: include(): Failed opening 'ROOT_PATHinc/products.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in <b>C:\xampp\htdocs\index.php</b> on line <b>26</b><br />
<ul class="products">
<br />
<b>Notice</b>: Undefined variable: products in <b>C:\xampp\htdocs\index.php</b> on line <b>30</b><br />
<br />
<b>Notice</b>: Undefined variable: products in <b>C:\xampp\htdocs\index.php</b> on line <b>33</b><br />
<br />
<b>Warning</b>: Invalid argument supplied for foreach() in <b>C:\xampp\htdocs\index.php</b> on line <b>33</b><br />
</ul>
</div>
</div>
<br />
<b>Notice</b>: Use of undefined constant ROOT_PATH - assumed 'ROOT_PATH' in <b>C:\xampp\htdocs\index.php</b> on line <b>47</b><br />
<br />
<b>Warning</b>: include(ROOT_PATHinc/footer.php): failed to open stream: No such file or directory in <b>C:\xampp\htdocs\index.php</b> on line <b>47</b><br />
<br />
<b>Warning</b>: include(): Failed opening 'ROOT_PATHinc/footer.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in <b>C:\xampp\htdocs\index.php</b> on line <b>47</b><br />
<?php
$pageTitle = "Unique T-shirts designed by a frog";
$section = "home";
include(ROOT_PATH . 'inc/header.php'); ?>
<div class="section banner">
<div class="wrapper">
<img class="hero" src="img/mike-the-frog.png" alt="Mike the Frog says:">
<div class="button">
<a href="<?php echo BASE_URL; ?>shirts.php">
<h2>Hey, I’m Mike!</h2>
<p>Check Out My Shirts</p>
</a>
</div>
</div>
</div>
<div class="section shirts latest">
<div class="wrapper">
<h2>Mike’s Latest Shirts</h2>
<?php include(ROOT_PATH . "inc/products.php"); ?>
<ul class="products">
<?php
$total_products = count($products);
$position = 0;
$list_view_html = "";
foreach($products as $product_id => $product) {
$position = $position + 1;
if ($total_products - $position < 4) {
$list_view_html = get_list_view_html($product_id,$product) . $list_view_html;
}
}
echo $list_view_html;
?>
</ul>
</div>
</div>
<?php include(ROOT_PATH . 'inc/footer.php') ?>
2 Answers
Mike Costa
Courses Plus Student 26,362 PointsLooks like your ROOT_PATH is not defined. Where ever you set that constant, you need to include that file where you plan to use that constant. For instance, if you have a config.php file
<?php
// config.php
define('ROOT_PATH', 'some/path/entered/here');
?>
You'll need to include it in any script you want to use that constant. So say index.php:
<?php
// index.php
include('/path/to/config');
include(ROOT_PATH . 'path/to/header');
?>
That way, the script you're trying to use the constant in has access to it. Hope this helps.
Aaron Lafleur
10,474 PointsBAM! Fantastic. Now if I could only get that time back. Thanks, Mike. As it turns out, I did not include('inc/config.php');
Mike Costa
Courses Plus Student 26,362 PointsNo problem! Glad I can help out. :)
Shawn Flanigan
Courses Plus Student 15,815 PointsShawn Flanigan
Courses Plus Student 15,815 PointsIf I could up-vote the title of your post, I would. Twice. Glad you got this sorted out!