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 Build a Simple PHP Application Creating the Menu and Footer Adding Active States to the Navigation

Sankara Narayanan
Sankara Narayanan
6,038 Points

Parse error: syntax error, unexpected 'shirts' (T_STRING) in C:\xampp\htdocs\inc\header.php on line 17

<li class="shirts <?php if ($section == "shirts") {echo ("on");}"><a href="shirts.php">Shirts</a></li>

<li class="contact <?php if ($section == "contact") {echo ("on");}"><a href="contact.php">Contact</a></li>```php
Sankara Narayanan
Sankara Narayanan
6,038 Points

Declared the appropriate variables in the shirts page and contact page. yet i got that error

Please help.

1 Answer

Jeremy Hayden
Jeremy Hayden
1,740 Points

Did you close out your php tags? <?php ?>

Looks like both classes have an error on them.

  1. Last line has '''php on the end.

  2. First line has <?php if ($section == "shirts") {echo ("on");}">

But i think you need a ?> in there

<?php if ($section == "shirts") {echo ("on");}?>">

might be what your looking for. Also check second class for same error.

Justin Black
Justin Black
24,266 Points

Exactly right. Both lines are missing the closing PHP Tag. When you combine logic with display like this, you always need both tags <?php and ?>. The only time it is not necessary ( and can even help in readability ) is in your business logic.

Sankara Narayanan
Sankara Narayanan
6,038 Points

Awesome Thank you so much for taking your time to solve my silly mistake.