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 trialMohammad Javanshah
991 PointsError for PHP Arrays and Control Structures task
I wrote this code for the challenge but it showed an error to me. Error=" Bummer! Use the negation operator to check that $role is NOT EQUAL to "admin". Preview ";
<?php
$username = 'sketchings'; //Available roles: author, editor, admin $role = 'editor';
//add conditional statement if($username && $role!="admin"){
echo "You do not have access to this page. Please contact your administratior.";
}; ?>
can you help me?
5 Answers
Mohammad Javanshah
991 PointsI cleaned all comments but the error is still there.
<?php $username = 'sketchings'; $role = 'editor'; if($username && $role!="admin"){ echo "You do not have access to this page. Please contact your administratior."; }; ?>
Christian Andersson
8,712 PointsIt looks like you have php code after your comment denotion - that will result in that code being part of the comment as well. Everything on one line that comes after the //
will be part of that comment. Make sure no code is after the comment denotion.
<?php
$username = 'sketchings'; //Available roles: author, editor, admin $role = 'editor';
if($username && $role!="admin"){ //add conditional statement
echo "You do not have access to this page. Please contact your administratior.";
}
?>
EDIT: Apparently you also had a semi-colon (;) after the closing bracket of your if
- remove it and you're set.
roberte
15,839 PointsSame problem even after incorporating all suggestions...
Stas Novsky
2,451 PointsI have the same problem
Kenan Xin
16,139 Pointssame problem here. Werid.
Christian Andersson
8,712 PointsRead my response above.
Christian Andersson
8,712 PointsChristian Andersson
8,712 PointsOkay, I've spotted the second error and updated the answer below.