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 Item Details and Redirection

Min Chin
Min Chin
401 Points

details page wont show up.

Im trying to load to my localhost http://localhost:8888/details.php?id=101, but it wont show up. Is there anything wrong with my code?

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


if (isset($_GET["id"])) {
    $id = $_GET["id"];
    if (isset($catalog[$id])) {
        $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-picure">

        <span>
            <img src="<?php echo $item["img"]; ?>" alt="<?php echo $item["title]; ?>" />
        </span>
</div>
    </div>
</div>
Adam Sommer
Adam Sommer
62,470 Points

I think you have a typo on this line:

<img src="<?php echo $item["img"]; ?>" alt="<?php echo $item["title]; ?>" />

Check your double and single quotes maybe.

1 Answer

Min Chin
Min Chin
401 Points

Your awesome Andrew. Its working now.

Reviewing line by line and comparing really does help. I had the same issue, it was a simple syntax error, details.php?id=101 works now. I was missing $ in $id. Thanks Adam.