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

Including the Footer and adding additional pages...

I just watched this video and set the files like Hoyt's. All was fine until I INCLUDED the Shirts.php and Href to the Header.php. The Shirts link will not load and gives the error of "Object not found!" I'm a complete layman and reviewed everything line for line. Any clues?

9 Answers

Kevin Korte
Kevin Korte
28,148 Points

Here is the video where he sets all that up!

http://teamtreehouse.com/library/build-a-simple-php-application/creating-the-menu-and-footer/including-the-header-2

This is will likely make a whole lot more sense. :)

Kevin Korte
Kevin Korte
28,148 Points

In your shirts.php file you need to require once the config file, and than include the header.php file.

In your header.php file, just build out your head, and your menu.

In you shirts.php file, you'll have something like

<?php
require_once("path/to/config.php");
include(ROOT_PATH . "path/to/header.php");
?>

Wow. I don't think he covered that. It's looks pretty foreign to me lol. Thank you. I will try it out.

Kevin Korte
Kevin Korte
28,148 Points

It's covered. This is where I learned how to do that. That code is almost cut and paste from Randy's lessons. Let me know if that fixes you up.

For kicks, your config.php should look something like

<?php
define("BASE_URL", "/folderroot/");
define("ROOT_PATH", $_SERVER["DOCUMENT_ROOT"] . "/folderroot/");

Obviously , replace the "folderroot" with the name of your root folder, inside of the server's root folder (usually htdocs, if you're on local).

Ok. I think I must have missed something. I haven't created a config.php yet. Looks like I need to go back a few lessons.

Kevin Korte
Kevin Korte
28,148 Points

Thats probably where you are getting messed up.

Thanks. Back to the drawing board ugh! I'll let you know what I find.

Go it!!! I went back through the tutorials and I realized that I created the Shirts.php files in the Include folder and it should be outside of that folder with the Index file. Whew! Thanks for your help.

Kevin Korte
Kevin Korte
28,148 Points

Awesome man! Good to hear