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.

	$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
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!";
7 Years
Discussion Span
Last Post by Tenaciousmug

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.