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 trialPhillip Gibson
1,731 PointsI'm getting an error
I followed along with the instructor but some how I still got an error message and I have no clue as to why, the error looks like this:
Parse error: syntax error, unexpected 'echo' (T_ECHO), expecting ',' or ';' in C:\xampp\htdocs\shirts.php on line 61
Phillip Gibson
1,731 PointsOkay here is my code.
<?php
$products = array();
$products[101] = array(
"name" => "Logo Shirt, Red",
"img" => "img/shirts/shirt-101.jpg",
"price" => 18
);
$products[102] = array(
"name" => "Mike the Frog Shirt, Black",
"img" => "img/shirts/shirt-102.jpg",
"price" => 20
);
$products[103] = array(
"name" => "Mike the Frog Shirt, Blue",
"img" => "img/shirts/shirt-103.jpg",
"price" => 20
);
$products[104] = array(
"name" => "Logo Shirt, Green",
"img" => "img/shirts/shirt-104.jpg",
"price" => 18
);
$products[105] = array(
"name" => "Mike the Frog Shirt, Yellow",
"img" => "img/shirts/shirt-105.jpg",
"price" => 25
);
$products[106] = array(
"name" => "Logo Shirt, Gray",
"img" => "img/shirts/shirt-106.jpg",
"price" => 20
);
$products[107] = array(
"name" => "Logo Shirt, Turquoise",
"img" => "img/shirts/shirt-107.jpg",
"price" => 20
);
$products[108] = array(
"name" => "Logo Shirt, Orange",
"img" => "img/shirts/shirt-108.jpg",
"price" => 25,
);
?><?php
$pageTitle = "Mike's Full Catalog Of Shirts";
$section = "shirts";
include('inc/header.php'); ?>
<div class="section shirts page">
<div class="wrapper">
<h1>Mike’s Full Catalog Of Shirts</h1>
<ul class="products">
<?php foreach($products as $product) {
echo "<li>";
echo '<a href="#">';
echo '<img src="' . $product["img"] . '" alt="' . $product["name"] . '">'
echo "<p>View Dietals</p>";
echo "</a>";
echo "</li>";
}
?>
</ul>
</div>
<?php include('inc/footer.php'); ?>
2 Answers
Hugo Paz
15,622 PointsPhilip, if you look at the error you can see that you have a parse error in the shirts.php file on the line 61. If you look at the code, you can see this on the line 60:
echo '<img src="' . $product["img"] . '" alt="' . $product["name"] . '">'
You forgot to add the semi colon at the end.
Phillip Gibson
1,731 PointsThanks for your help, I can't believe I missed that
Neal Williams
14,597 PointsHugo's right. (I was asked to answer this question via email. Not sure why.)
Phillip Gibson
1,731 PointsI may be the reason for that email, I posted the question to all of the people that tree house recommended, but I think that you also get points for answering them too because I got an email asking me to do the same last week.
Hugo Paz
15,622 PointsHugo Paz
15,622 PointsHi Philip,
Could you please post your shirts.php code here please.