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 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,793 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.