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 PHP Arrays and Control Structures PHP Conditionals Operators

Claudio Vendrame
Claudio Vendrame
4,964 Points

I can't understand the task. Validate by editor or author, editor, admin? I get the message: Use negative operator.

This is what I have: //add conditional statement if (isset($username) && $role <> "admin"){ echo "You do not have access to this page. Please contact your administratior."; }

index.php
<?php
$username = 'sketchings';
//Available roles: author, editor, admin
$role = 'editor';

//add conditional statement
if (isset($username) && $role <> "admin"){
  echo "You do not have access to this page. Please contact your administratior.";
} 
Claudio Vendrame
Claudio Vendrame
4,964 Points

Hello there! Thank you very much for the help. It worked. I could swear I tried " !=, !==, !=== and <>" all the possibilities . Small problem but great help.

Thanks again

1 Answer

Luc de Brouwer
seal-mask
.a{fill-rule:evenodd;}techdegree
Luc de Brouwer
Full Stack JavaScript Techdegree Student 17,939 Points

Hi Claudio, It's rather an easy problem to solve. They are asking you to check a statement with 2 conditions.

if a username is set AND the role of admin is not equal to 'admin' then echo blabla. You need to use a logical operator in this case you'll have to use != because you want to echo a message that says you are not allowed to acces the page because you're no admin. != stands for not equal to and is the negative operator you are looking for

Example: if (isset($username) && $role != 'admin') echo stuff in here