Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,109 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,109 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,109 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,109 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,109 Points

Awesome man! Good to hear