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 Integrating PHP with Databases Limiting Records in SQL Getting Specific with Queries

Images are not loading?

Somewhere in the last section, the images stopped loading and the styles have changed. Very curious... Can anyone help me get this ironed out?

My code this far is here: https://w.trhou.se/iu7h5lrd6z

Thanks in advance! :D

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! I'm not sure exactly what happened, but I forked your workspace and took a look around. In functions.php around line 79, your code differs a bit from Alena's.

This is your code:

function get_item_html($item) {
    $output = "<li><a href='details.php?id="
        . $id . "'><img src='" 
        . $item["media_id"] . "' alt='" 
        . $item["title"] . "' />" 
        . "<p>View Details</p>"
        . "</a></li>";
    return $output;
}

And this is Alena's:

function get_item_html($item) {
    $output = "<li><a href='details.php?id="
        . $item["media_id"] . "'><img src='" 
        . $item["img"] . "' alt='" 
        . $item["title"] . "' />" 
        . "<p>View Details</p>"
        . "</a></li>";
    return $output;
}

When you preview your work you'll notice that there's an error saying that $id isn't defined. Your code is attempting to use this variable name, but it doesn't exist in this context. Where you have $id, Alena has $item["media_id"]. Where you have $item["media_id"], Alena has $item["img"]. When I correct these things to look like the function at the bottom, your images load and no errors are displayed.

Hope this helps! :sparkles:

This was great! What a find! Thank you :D