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 Build a Simple PHP Application Creating the Menu and Footer Including the Footer and Adding Additional Pages

Aaron Lafleur
Aaron Lafleur
10,474 Points

Can't seem to get shirts.php to load.

I've gone through the questions previously posted about this, but I'm still not having much luck getting shirts.php to load. I do, however get localhost/shirts.php in the address bar, but the content shows "Object not found". Not sure what to check next.

index.php

<?php include('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="#">
                        <h2>Hey, I&rsquo;m Mike!</h2>
                        <p>Check Out My Shirts</p>
                    </a>
                </div>
            </div>

        </div>

        <div class="section shirts latest">

            <div class="wrapper">

                <h2>Mike&rsquo;s Latest Shirts</h2>

                <ul class="products">
                    <li><a href="#">
                            <img src="img/shirts/shirt-108.jpg">
                            <p>View Details</p>
                        </a>
                    </li><li>
                        <a href="#">
                            <img src="img/shirts/shirt-107.jpg">
                            <p>View Details</p>
                        </a>
                    </li><li>
                        <a href="#">
                            <img src="img/shirts/shirt-106.jpg">
                            <p>View Details</p>
                        </a>
                    </li><li>
                        <a href="#">
                            <img src="img/shirts/shirt-105.jpg">
                            <p>View Details</p>
                        </a>
                    </li>                               
                </ul>

            </div>

        </div>



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

header.php


<html>
<head>
    <title><?php echo "Shirts 4 Mike"; ?></title>
    <link rel="stylesheet" href="css/style.css" type="text/css">
    <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Oswald:400,700" type="text/css">
    <link rel="shortcut icon" href="favicon.ico">
</head>
<body>

    <div class="header">

        <div class="wrapper">

            <h1 class="branding-title"><a href="./">Shirts 4 Mike</a></h1>

            <ul class="nav">
                <li class="shirts"><a href="shirts.php">Shirts</a></li>
                <li class="contact"><a href="contact.php">Contact</a></li>
                <li class="cart"><a href="#">Shopping Cart</a></li>
            </ul>

        </div>

    </div>

    <div id="content">

shirts.php

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

        <div class="section page">

            <h1>Mike&rsquo;s Full Catalog Of Shirts</h1>

        </div>

<?php include('inc/footer.php'); ?>
Gabriel Tartaglia
Gabriel Tartaglia
41,581 Points

Hi Aaron!

Can you take a print of the page that appears when you access the localhost/shirts.php? Ow! And if there is any errors you can post here too, will help to discover what is the problem.

I think you are making some mistake while typing the shirts.php path in your browser, you better check that. As far as i know a php file never show "object not found" normally.

Sean T. Unwin
Sean T. Unwin
28,690 Points

Could you open your browser Dev Tools and in the Network tab, press record then reload the page, stop recording and tell us which files are loaded?

Also, if you could check the Elements tab and see what, if any, HTML has been loaded.

Sean T. Unwin
Sean T. Unwin
28,690 Points

Thank you, Aaron. Nice to see a fellow Canuck here and from Ontario as well! :-D

4 Answers

Aaron Lafleur
Aaron Lafleur
10,474 Points

Well, somehow through messing around with file locations I managed to solve the problem. I relocated my shirts.php file from the 'inc' folder to the 'htdocs' folder. For whatever reason, it worked. I wish I could come up with a better reason that worked, (is this what you were describing, Sean?), but perhaps once I get some more experience I'll have a better idea.

Thanks, all.

Sean T. Unwin
Sean T. Unwin
28,690 Points

Glad you sorted it out! So the problem was shrits.php was in the inc/ directory when it should have been up one in with the other main files such as index.php and contact.php?

Good luck and have fun on your adventures! :-)

Sean T. Unwin
Sean T. Unwin
28,690 Points

What is the URL to the main project from localhost? I ask because the URL to the page you posted is pointing to the root directory of your localhost. So you'd probably want to check that unless the project is in your root directory (in which case I would suggest moving it to it's own directory like localhost/shirts4mike/).

Sean T. Unwin
Sean T. Unwin
28,690 Points

Here's a possibility is when you saved the file in whichever editor you used it saved the file as a text file or something so check the file extension in your project directory to make sure it's says shirts.php and not something like shirts.php.txt.

Aaron Lafleur
Aaron Lafleur
10,474 Points

As a Canadian, are you frustrated by the spelling of colour? My CSS lessons would have gone a lot faster if the word was spelled properly. ;)

So far as I can tell, the project is in the root directory. I simply followed the steps in the videos and this is what has happened so far. I have checked all my link elements, checked my syntax, searched 'shirts' and found only my shirts.php file, and a folder named shirts. Subsequently, I checked the file type: definitely .php and not .txt. Also, I should note, the 'Contacts' link works just fine, and displays 'localhost/contacts.php' in the browser. Unless I've missed something glaringly obvious, which happens frequently, the solution may be outside my realm of experience. On that note, I'm going to go through some more rudimentary PHP lessons and find a couple tutorials on XAMPP.

Aaron Lafleur
Aaron Lafleur
10,474 Points

Yes, that is correct. I have now gained some insight into the importance of proper file structure. :)