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

Error 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

I 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."; }; ?>

Okay, I've spotted the second error and updated the answer below.

It 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.

Same problem even after incorporating all suggestions...

Stas Novsky
Stas Novsky
2,451 Points

I have the same problem

Kenan Xin
Kenan Xin
16,139 Points

same problem here. Werid.

Read my response above.