0

I'm fairly new to PHP, and I don't know a lot about it. I have had a go, but I don't know where I have gone wrong.

The code:

<?php 
include('config.php');
    if(isset($_SESSION['username']) and $_SESSION['moderator'] {
    } else {
    header("location:noaccess.php");
}
?>

The error: Parse error: syntax error, unexpected '}' in E:\LocalWebHost\htdocs\forum\test.php on line 4

Darth
  • 63
  • 11

1 Answers1

2
<?php 
include('config.php');
    if(isset($_SESSION['username']) and $_SESSION['moderator']) {
    } else {
    header("location:noaccess.php");
}
?>

In line 3, your if statement needs closing ).

Just Rudy
  • 700
  • 11
  • 28
  • How would I go about making it so if moderator = 1 in my mysql, it will let you access the page? – Darth Sep 30 '16 at 19:58
  • Ah, try changing your `if` statement to: `if(isset($_SESSION['username']) && $_SESSION['moderator'] == 1)`. I think this is more explicit. Are you setting $_SESSION['moderator'] anywhere? – Just Rudy Sep 30 '16 at 20:11
  • @Martin Rudy answered your original question and what you're asking about "if something equals 1" is another question. You reposted the same one related to your comment http://stackoverflow.com/questions/39799119/show-page-if-mysql-value-is-met and this question should be marked as solved instead of asking another question within the same one. – Funk Forty Niner Sep 30 '16 at 22:46