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

Samandar Mirzayev
Samandar Mirzayev
11,834 Points

Guys, I need your help I stuck in PHP. I coded but seems like an all correct but not working. I don't know why.

<?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-picture"> <span> <img src="<?php echo $title['img'] ?>" alt="<?php echo $title['title'] ?>" /> </span> </div> </div> </div>

<?php include("inc/footer.php"); ?>

Samandar Mirzayev
Samandar Mirzayev
11,834 Points

it is showing this line $pageTitle = $item["title"]; =>Notice: Undefined variable: item in /home/treehouse/workspace/details.php on line 17

and this line as well <img src="<?php echo $title['img'] ?>" alt="<?php echo $title['title'] ?>" /> => The requested URL /<br /><b>Notice</b>: Undefined variable: title in <b>/home/treehouse/workspace/details.php</b> on line <b>28</b><br /> was not found on this server. Why...???

2 Answers

My observation is that you never defined $title in your PHP block above the HTML. It first appears in the line that is causing the error, so before you use $title, you need to assign it a value. Either that or you meant something besides $title when referring to that variable on the line in question. I think that should help.

Samandar Mirzayev
Samandar Mirzayev
11,834 Points

but for another page it is working anyway i will check again.

Samandar Mirzayev
Samandar Mirzayev
11,834 Points

yeah u right bro i have got it mine mistake thanks bro i really appriciated

Another set of eyes always helps - I'm glad it worked!