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 trialJohn Lukacs
26,806 PointsBuild a basic PHP website
The workspaces do not work when previewed in browser at creating and displaying function. Hopefully @Alena_Holligan can shed some light on this issue. Do you know how to tag her in this and how to show a display pick
Codin - Codesmite
8,600 PointsHi John, can you link your workspace or post your code here, from the error it sounds like their may be a syntax error in your foreach loop.
6 Answers
Codin - Codesmite
8,600 PointsHi Alena Holligan Taking a quick look at the workspace I have found 4 typos causing the workspace not to work as John describes.
in functions.php
On line 4
.$item["img] . "' alt'"
should be:
.$item["img"] . "' alt'"
On line 7
."</a></li>';
should be:
."</a></li>";
in index.php:
On line 16
$random = array_rand($catalog, 4)
should be:
$random = array_rand($catalog, 4);
in catalog.php:
On line 2
include("inc/fucntions.php");
should be:
include("inc/functions.php");
John Lukacs nothing you have done wrong, just some minor typo errors in the workspace that need to be fixed, thankyou for alerting us to the problem :)
John Lukacs
26,806 PointsOk thanks that takes care of that but now I am getting a new error message
Warning: include(inc/fucntions.php): failed to open stream: No such file or directory in /home/treehouse/workspace/catalog.php on line 2
Warning: include(): Failed opening 'inc/fucntions.php' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in /home/treehouse/workspace/catalog.php on line 2
and Fatal error: Call to undefined function array_category() in /home/treehouse/workspace/catalog.php on line 30
The images don't show
Alena Holligan
Treehouse TeacherHi John Lukacs
If you could take a "snapshot" of your workspace (upper right hand corner) and share a link here, that would be most useful.
Also which video did you start this workspace on?
John Lukacs
26,806 PointsI haven't changed a thing In workspaces I simply open up workspaces from videos like "Random fun with arrays" or "creating the display function. " I then view in browser and all I get back is a error message. I tried going threw the lesson but I still recieve an error message from line 17 the foreach loop I took a snap shot but I not sure how to share. https://w.trhou.se/uum869s0pa
John Lukacs
26,806 PointsOk I worked out the bugs but the photo's don't show any idea's
John Lukacs
26,806 Points!~~~ html <?php function get_item_html($id, $item){ $output = "<li><a href='#'><img src'" .$item["img"] . "' alt'" .$item["title"]."' />" . "<p>View Details</p>" ."</a></li>"; return $output; }
This is where the function runs to get the image do this look right to you?
Alena Holligan
Treehouse TeacherTry this for the function
function get_item_html($id, $item){
$output = "<li><a href='#'><img src='"
. $item["img"] . "' alt'"
. $item["title"]."' />"
. "<p>View Details</p>"
. "</a></li>";
return $output;
}
John Lukacs
26,806 PointsIt still does't display any of the photos in any of the books movies or suggest
Alena Holligan
Treehouse Teacherwas missing a comma after src try pasting that function again (I fixed it)
John Lukacs
26,806 PointsJohn Lukacs
26,806 PointsLet me clearify the workspaces are not working. When previewed you get this error Parse error: syntax error, unexpected 'foreach' (T_FOREACH) in /home/treehouse/workspace/index.php on line 17 The problem starts at "Creating and displaying function"