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 trialJustin Greenough
2,865 Pointsredirecting-invalid-shirt-ids not redirecting
I've been following this php 'Shirts 4 Mike' tutorial very closely, and all my code has functioned as predicted up until now. For some reason, although my code seems to be identical to Randy's, the redirect on erroneous or missing shirt id doesn't function: my page is just left blank. I've included the relevant section of code (nothing'd been modified since functioning properly):
<?php include("inc/products.php");
if (isset($_GET["id"])) {
$product_id = $_GET["id"];
if (isset($products[$product_id])) {
$product = $products[$product_id];
}
}
if (!isset($product)) {
header("Location: shirts.php"):
exit();
}
$section = "shirts";
$pageTitle = $product["name"];
include("inc/header.php"); ?>
2 Answers
Ron McCranie
7,837 PointsLooks like it might have been the semi-colon at the end of this line header("Location: shirts.php"):
you had a colon in the code you pasted.
Justin Greenough
2,865 PointsReally! So hard to find little things in the code sometimes. Thanks for your hawk vision Ron!
Justin Greenough
2,865 PointsJustin Greenough
2,865 PointsWell I'm not sure what's happened, but it seems to be functioning now. Thanks for all the help you active community of users you!