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
San Yuk Cheng
Courses Plus Student 1,486 PointsConditional statement for Shirts 4 mike.
I added the conditional statement on my header.php. So, when I am either on the shirts or contact page, the regarding link would be underlined. However, when I go back to the index.html. An error showed up: Notice: Undefined variable: section in C:\wamp\www\inc\header.php on line 17 Call Stack #TimeMemoryFunctionLocation 10.0156140512{main}( )..\index.php:0 20.0156142736include( 'C:\wamp\www\inc\header.php' )..\index.php:3 ">
Notice: Undefined variable: section in C:\wamp\www\inc\header.php on line 17 Call Stack #TimeMemoryFunctionLocation 10.0156140512{main}( )..\index.php:0 20.0156142736include( 'C:\wamp\www\inc\header.php' )..\index.php:3 ">
The following are my codes for line 17 and 18. Line 17: <li class="shirts <?php if($section=="Shirts"){echo "on";} ?>"><a href="shirts.php">Shirts</a></li> Line 18: <li class="contact <?php if($section=="contact"){echo "on";} ?>"><a href="contact.php">Contact</a></li>
3 Answers
Victor Arellano
12,045 PointsHello San.
Maybe you should use the isset() function to verify if the $section variable is being passed to the page. Another option is to define it in the index page before including the header.
Hope this helps.
San Yuk Cheng
Courses Plus Student 1,486 PointsThanks! Defining $section totally works!
Daniel Hurd
12,987 PointsI had this same problem! Thanks for the help Victor!
Victor Arellano
12,045 PointsGlad it helped!