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 trialBryan Haire
2,971 Pointsswitch statment not working
is says that task 1 is no longer passing when i enter this. what is wrong? can anyone try and see if it works or not?
<?php
//Available roles: admin, editor, author, subscriber
if (!isset($role)) {
$role = 'subscriber';
}
//change to switch statement
switch ($role) {
case 'admin':
echo "As an admin, you can add, edit, or delete any post.";
break;
case 'editor':
echo "As an editor, you can add or edit any post, and delete your own posts.";
break;
case 'author':
echo "As an author, you can add, edit, or delete your own post.";
break;
default:
echo "You do not have access to this page. Please contact your administrator.";
}
?>
Bryan Haire
2,971 Pointsnope says task 1 is no longer passing
Bryan Haire
2,971 PointsThe exercise instructions: Step 1: Add a check for the role of "editor" and display the following message: As an editor, you can add or edit any post, and delete your own posts. Step 2: Add a check for the role of "author" and display the following message: As an author, you can add, edit, or delete your own post.
says this after i try it: Oops! It looks like Task 1 is no longer passing.
Don Macarthur
28,430 PointsHey Bryan,
Something weird is going on for you. I just did the challenge and it passed then when I compared my code to yours I could see no difference.
I did the challenge again but this time copied and pasted your code and it passed just fine.
Are you still having issues with it? Or do you have some more code outside of what you have pasted above which we cannot see and is maybe affecting the compiler?
Cheers Don :-)
Bryan Haire
2,971 Pointsthank you Don!!! you were right, there was something wrong when i tried before but it went through just fine this time.
Robert Kulagowski
4,954 PointsRobert Kulagowski
4,954 PointsJust for grins, add a break to the default case and see if that changes anything.