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 trialSimon Strömberg
1,423 PointsBuilding the Shirt Details Page
<?php
// Enables error reporting
error_reporting(E_ALL);
ini_set("display_errors", 1);
include("inc/products.php");
// Rest of yout code goes here...
?>
$product_id = $_GET["id"];
$product = $products[$product_id];
$section = "shirts";
$pageTitle = $product["name"];
include("inc/header.php"); ?>
<div class="section page">
<div class="wrapper">
<div class="breadcrumb"><a href="shirts.php">Shirts</a> > <?php echo $product['name']; ?></div>
<div class="shirt-picture">
<span>
<img src="<?php echo $product['img']"; ?> alt="<?php echo $product['name']"; ?>
</span>
</div>
</div>
</div>
5 Answers
Simon Strömberg
1,423 PointsI get an white blank page on the url http://port-80-o8ngbeg2s8.treehouse-app.com/shirt.php?id=101
What is wrong in the code?
Lynde Roberts
8,016 PointsSimon,
Looks like a couple of syntax errors. You are closing your image src and alt attributes inside of your PHP code.
The following:
```<img src="<?php echo $product['img']"; ?> alt="<?php echo $product['name']"; ?>
should be...
<img src="<?php echo $product['img']; ?>" alt="<?php echo $product['name']; ?>">
I moved the double quote outside of the closing PHP tags and added a greater than to close your image tag.
Does that solve the problem for you?
Simon Strömberg
1,423 PointsHello, thanks, but now it looks like this: http://puu.sh/eKCP9/e736099cbc.png
Regards
Lynde Roberts
8,016 PointsSimon,
Can you post the entire code you have for shirts.php?
Simon Strömberg
1,423 Points<?php
// Enables error reporting
error_reporting(E_ALL);
ini_set("display_errors", 1);
include("inc/products.php");
// Rest of yout code goes here...
?><?php
$pageTitle = "Unique t-shirts";
$section = "shirts";
include('inc/header.php'); ?>
<div class="section shirts page">
<div class="wrapper">
<h1>Mikes’s Full Catalog Of Shirts</h1>
<ul class="products">
<?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>
</div>
</div>
<?php include('inc/footer.php'); ?>
Lynde Roberts
8,016 PointsPlease enclose your code inside of three backticks ( ` ) so it will be displayed properly here in the forum. Three before your code and three after to close it. Thanks.
Simon Strömberg
1,423 PointsDoesnt work
Lynde Roberts
8,016 PointsTake a look at the Markdown Cheatsheet (link below the comment box) for help with using backticks.
Simon Strömberg
1,423 Pointshttp://puu.sh/eKISB/5c207e85a8.png
Can you help ?
Ricky Catron
13,023 PointsRicky Catron
13,023 PointsI added three backticks ``` to before and after your code so it is displayed correctly in the forum.
--Ricky