Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.