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 Basic PHP Website (2018) Listing and Sorting Inventory Items Displaying Item Details

Parse error for details page

Hey guys! Looks like I typed the code exactly as Alena had it in the video, however I am getting this error trying to display the page in a browser:

Parse error: syntax error, unexpected '?> ' in /home/treehouse/workspace/details.php on line 55

Here's the code I have:

'''php <?php include("inc/data.php"); include("inc/functions.php");

if(isset($_GET["id"])){ $id = $_GET["id"]; if (isset($catalog[$ud])) { $item = $catalog[$id]; } }

if (!isset($item)) { header("location:catalog.php"); exit; } $pageTitle = $item["title"]; $section = null; include("inc/header.php"); ?>

<div class="section page">

<div class="wrapper"> <div class="media-picture"> <span> <img src="<?php echo $item["img"]; ?>" alt="<?php echo $item["title"]; ?>" /> </span> </div>

<div class="media-details">

  <h1><?php echo $item["title"];?></h1>
  <table>

    <tr>
      <th>Category</th>
      <td><?php echo $item["category"]; ?></td>
    </tr>
    <tr>
      <th>Genre</th>
      <td><?php echo $item["genre"]; ?></td>
    </tr>
    <tr>
      <th>Format</th>
      <td><?php echo $item["format"]; ?></td>
    </tr>
    <tr>
      <th>Year</th>
      <td><?php echo $item["year"]; ?></td>
    </tr>
    <?php
    if (strtolower($item["category"] == "books"){ 
    ?>
      <tr>
      <th>Authors</th>
      <td><?php echo $item["authors"]; ?></td>
    </tr>
    <tr>
      <th>Publisher</th>
      <td><?php echo $item["publisher"]; ?></td>
    </tr>
    <tr>
      <th>ISBN</th>
      <td><?php echo $item["isbn"]; ?></td>
    </tr>

    <?php } ?>
  </table>
</div>

</div> </div> '''

1 Answer

Antonio De Rose
Antonio De Rose
20,885 Points

I haven't gone through the video to comment, but when I went through the code, at a glance, I see there isnt the second bracket in the below mentioned.

<?php
    if (strtolower($item["category"] == "books")){ 
 ?>

Awesome thanks Antonio! I'll add that and check to see if it fixed it, most likely it will.