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
Robbie Thomas
31,093 PointsIncluding the products array
Not a challenge question, but I'm going along with Randy's vid with the said title. I got everything done but when I go to the shirts.php page, I get this:
Notice: Undefined variable: products in C:\xampp\htdocs\shirts.php on line 13
Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\shirts.php on line 13
Here's my code, it seems to match Randy's:
<ul class="products">
Line 13 ---> <?php foreach($products as $product_id => $product) {
echo "<li>";
echo '<a href="shirt.php?id=' . $product_id . '">';
echo '<img src="' . $product["img"] . '" alt="' . $product["name"] . '">';
echo "<p>View Details</p>";
echo "</a>";
echo "</li>";
}
?>
</ul>
1 Answer
miguelcastro2
Courses Plus Student 6,573 PointsIt appears you have not included the file that defines the $products array and hence the error.