Q: the second "if" statement describes an error if tokens = less than 10. Why is it an error over 10? So this php i have here is an update mysql query stating that if tokens < 10 echo "some error".. problem is that every time i execute the code it returns the error. in the same way every time even if tokens = 11.. I simply don't understand 
FULL CODE
    

//if not logged in redirect to login page
if(!$user->is_logged_in()){ header('Location: login.php'); exit(); }

//define page title
$title = 'Dashboard ~ Pixel Jag.';

//include header template
require('layout/header.php'); 
?>
<div class="container">
<div class="panel panel-default">
 <?php
$servername = "localhost";
$username = "user";
$password = "pass";
$dbname = "database";

// Create connection
$db = mysqli_connect($servername, $username, $password, $dbname);

// Check connection
if (!$db) {
die("Connection failed: " . mysqli_connect_error());
}
if (($_SESSION['tokens'] < 10)) {
echo "<ul class='list-group'><li class='list-group-item list-group-item-danger'>You do not have enough tokens!</li></ul>";
}
else {
$sql = "UPDATE members SET tokens=tokens - 10, tokenstatus='(Pending Tokens)' ,tokenswith=tokenswith + 10, tokenstatus1='(Pending Tokens)' WHERE username = '".($_SESSION['username']) ."'";
}
if (mysqli_query($db, $sql)) {
echo "<ul class='list-group'><li class='list-group-item list-group-item-success'><h4>Record updated successfully!</h4></li></ul>";
} else {
echo "Error updating record: " . mysqli_error($db);
}

mysqli_close($db);
?> 

<div class="panel-footer">
<a href="index.php"><h4>Back To Dashboard..</h4></a>
</div>
</div>
</div>
<?php 

//include header template
require('layout/footer.php'); 
?>


A: It must be because there value in session variable is less than ten. 
Try checking the following things
1. Did you start the session?
2. If yes, the session is started then try to echo the value of session
3. If the session is started and value shows zero go where you are trying to put the session variable value and check if there is some spelling error or some insertion error.
