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 trialCody Richard
1,976 PointsWhat am I doing wrong?
I am on the basic build a php website here https://teamtreehouse.com/library/build-a-basic-php-website/building-a-media-library-in-php/working-with-get-variables
I am following along with the video. As far as I can tell I have done exactly as instructed but when adding the _GET variable I am getting the following errors.
Notice: Use of undefined constant _GET - assumed '_GET' in /home/treehouse/workspace/catalog.php on line 3
Warning: Illegal string offset 'cat' in /home/treehouse/workspace/catalog.php on line 3
Notice: Use of undefined constant _GET - assumed '_GET' in /home/treehouse/workspace/catalog.php on line 5
Warning: Illegal string offset 'cat' in /home/treehouse/workspace/catalog.php on line 5
Notice: Use of undefined constant _GET - assumed '_GET' in /home/treehouse/workspace/catalog.php on line 7
Warning: Illegal string offset 'cat' in /home/treehouse/workspace/catalog.php on line 7
Here is my code for the page
<?php $pagetitle = "Full Catalog"; if (_GET["cat"] == "books") { $pagetitle = "Books"; } else if (_GET["cat"] == "movies") { $pagetitle = "movies"; } else if (_GET["cat"] == "music") { $pagetitle = "music"; }
include("inc/header.php"); ?> <div class="section page"></div> <h1><?php echo $pagetitle; ?></h1>
<?php include("inc/footer.php"); ?>
I am a noob trying to get this down please help!!!
2 Answers
Lin Lu
29,171 PointsYou're missing the "$" sign before "_GET" :)
Cody Richard
1,976 Pointsoh right I fixed it thanks!!! I was either too sleepy or maybe i shouldnt take up coding lol
Lin Lu
29,171 PointsYou're welcome :) It's normal to make mistakes like that when you just started coding, we have all been there haha :p