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 Header

Hi just finished the above mentioned video and passed the quiz just fine. The problem that I am facing is the practical. I am using sublime text as my text editor and I literally went over the code line for line comparing mine with the videos when I started having this problem.

I have set up my header.php page and included it in both my index and contact pages. I have saved both and was checking them in my browser. The contact link does carry me to the contact page but the page is all but blank except for what is written in the h1 tag.

May someone please stare me in the right direction with this. I don't want to just pass the quizzes I need to be able to do the practical as well.

Thanks in advance!

14 Answers

I had to remove the mamp software and start over from there. I had missed a step in setting up my server. Also although I had included the proper code in the header.php file I had failed to cut(remove) this code from my index.php file.

Once I resolved both those issues , they worked perfectly. :)

Yes I do . Maybe I need to remove mamp and everything and start from scratch. I'll look into that when I get off tonight. Thanks :)

Try that, but I'm not sure that t's your answer. Did you organize everything in the appropriate folders as Treeouse showed?

I completely understand that you want practical applications. Could you by chance post your code on JSFiddle or something of the sort. You never know, you might have a few inconsistencies that you may have missed - that way we can see if there's an error or something else wrong with your code.

Thanks for the reply I just erased it all to start from scratch. If the error occurs again I will paste the code if not I will update you all the same. :)

Ok, sounds great. Let us know how it goes!

I did try it again the h1 tag that was showing up on the page in the browser has disappeared but the page is still not loading properly.

The index.php code is : <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</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">

    <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>

</div>

<div class="footer">

    <div class="wrapper">

        <ul>        
            <li><a href="http://twitter.com/treehouse">Twitter</a></li>
            <li><a href="https://www.facebook.com/TeamTreehouse">Facebook</a></li>
        </ul>

        <p>&copy;<?php echo date('Y');?> Shirts 4 Mike</p>

    </div>

</div>

</body> </html>

The code that I put in header.php is :<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</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">

My include php tag is :<?php include('include/header.php'); ?>

I have included this in index.php and in contact.php

But it is still not showing up properly. Do you see what I'm doing wrong ?

hmmm...this looks okay to me. I'm not exactly sure, either. Have you downloaded the files from Treehouse -- do they work? Maybe Randy Hoyt can give some suggestions.

I did download them from treehouse. What I will do is delete them and try again as soon as I finish fighting with a jquery slider. Thanks for your help and if this works I'll update here just incase someone else runs into this problem.

Okay I started over with this. Used the same code and now my contact page is completely blank I definitely need some help here !

Do you have PHP instaled and running?

Yep literally step by step.

Hey guys I know that it's been a few days but, I finally got a chance to start over. I figured the problem out and look forward too continuing in PHP. Thanks a bunch.

Could you let us know what the problem was and how you resolved it? Other students might encounter this problem too!