Ok, I have my username set as 1 under admin and this other account set as 0 under admin. But it's not showing the page to any of the accounts and only showing the else statement. Does anyone know whats the problem? Im so confused and I have been staring at this code for a while now.

<?php
	include("haha.php");
	$cxn = mysqli_connect($dbhost,$dbuser,$dbpassword,$dbdatabase) or die("Couldn't connect to server");
	$sql = "SELECT `admin` FROM `Member` WHERE `username`='{$_SESSION['username']}'";
	$result = mysqli_query($cxn,$query) or die(mysqli_error($cxn));
	$row = mysqli_fetch_array($result);
	if($row['admin'] == 1)
	{
There is code here that shows the page, but that works fine and I already tested it so I wont hog up the space with it. xD
}
}else{
echo "You aren't allowed to view this page because you are not admin.<br>
Click <a href='explore.php'>here</a> to go back to the site!";
}
?>

Why do you have backticks around "admin", "Member", and "username"? I've never seen those used in a SQL statement, but maybe I'm just ignorant. In any case, try

$sql = "SELECT admin FROM Member WHERE username='{$_SESSION['username']}'";

and see if that works.

No it doesn't. This one professional guy told me to do it because thats how you should code it so it looks professionally done.. ? I dont know.

Nevermind it was a simple variable mistake. I had $sql and instead I was trying to result the $query and $cxn. xD And there was no $query variable.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.