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

In details page , i am not getting the image just only shows the alternate text .

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

2 Answers

Simon Coates
Simon Coates
28,694 Points

Your post isn't attached to any video or challenge, so it's difficult to know what this is about. When a value goes missing, you want to take a look at what is in the variable. When developing using something like var_dump($title) might be used to confirm that what is in variable is what you expect (if the value is missing and you haven't got the variable name wrong, you then work back to where the variable came from to see what went wrong). If the src is present, you might want to look at the path contained for src. My other advice would be that if this is related to a workspace, you can post a snapshot so people can help you debug. (see https://teamtreehouse.com/library/previews-and-snapshots)

Simon Coates
Simon Coates
28,694 Points

A follow up. I ran the following

<?php
        //Enter your code here, enjoy!

$title = array("img" => "img\something.jpg",             );

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

and got:

<div class="media-picture">
  <span>
    <img src="img\something.jpg" alt="" >
    </span>
  </div>

So the first step is confirm there is a variable called title containing a value for img. (Unless there is a value for src - but it is faulty)