Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's wrong with this function?

I'm using this function to determine whether my application should be online or offline:

function online() {
   if ($online == "0") {
     if($_SESSION['exp_user']['userlevel'] != "1") {
          include("error/offline.php");
          exit();
                                                   } 
                        }
                   }

However, with the data value set to 0 in the database, and $online does = '0', why is error/offline.php not included for those whoose user level is not 1?

Thanks :)

like image 205
bear Avatar asked Apr 22 '26 22:04

bear


1 Answers

What is $online, a global variable? If so you have to do global $online to access it inside a function. Right now $online is a default null value, which is not equal to string "0".

like image 125
chaos Avatar answered Apr 25 '26 12:04

chaos