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 Header

Martina Carrington
Martina Carrington
15,754 Points

Parse error: syntax error, unexpected '4' (T_LNUMBER), expecting ',' or ';' in C:\xampp\htdocs\index.php on line 3

i put all the folders in the htdoc and i received this syntax error message

6 Answers

index.php has an error in it. But we need to see the contents before we can help you. Please post the contents of index.php using the rules in the Markdown Cheatsheet link near bottom of this page.

Martina Carrington
Martina Carrington
15,754 Points

rtholen , here is my index.php code <?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')

I have not seen your video so I am only going on what I see here, which may be out of context. I don't believe you should change the file back to index.html. The PHP processor running on the server reads/parses your index.php file and converts it to an html file. Then sends it to the client's browser. If the contents of your index.php are as shown above, then you still need to add the normal html, head, and body tags to index.php.They are missing. For example, all your divs above should be wrapped inside body tags, like they would be if it was a normal HTML file. Try adding those missing tags.

Please copy and paste your entire index.php code here. What you quoted above would not throw that error I don't think.

You can change a normal html page and change it to .php and have no errors.

Martina Carrington
Martina Carrington
15,754 Points

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');?>

edited to format code quote. Ted Sumner

Is this the full contents of your index.php? I believe this file is meant to be parsed by a server into a valid HTML doc. As is, I don't see the needed html, head, and body tags in index.php needed for valid HTML output.

Martina Carrington
Martina Carrington
15,754 Points

@Rtholen , oh ok ! you think i should change it back to index. html

Martina Carrington
Martina Carrington
15,754 Points

I re-watch php course called including the header to make sure everything is link but i still the same problem . i hope don't sound like a nag lol

Your error problem is related to the problem this post you made: https://teamtreehouse.com/community/how-do-use-the-localhost. I have posted the solution there also. You need to change line of your header.html to this:

<?php
/// the change is below this comment:

<title><?php echo "Shirts 4 Mike";?></title>