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

PHP Build a Simple PHP Application Integrating with PayPal Building the Shirt Details Page

Simon Strömberg
Simon Strömberg
1,423 Points

Building 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> &gt; <?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>
Ricky Catron
Ricky Catron
13,023 Points

I added three backticks ``` to before and after your code so it is displayed correctly in the forum.

--Ricky

5 Answers

Simon,

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
Simon Strömberg
1,423 Points

Hello, thanks, but now it looks like this: http://puu.sh/eKCP9/e736099cbc.png

Regards

Simon,

Can you post the entire code you have for shirts.php?

Simon Strömberg
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&rsquo;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'); ?>

Please 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.

Take a look at the Markdown Cheatsheet (link below the comment box) for help with using backticks.