Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. how to deal with bool?

how to deal with bool?

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
mysqlcomhelptutorialquestion
3 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jassim Rahma
    wrote on last edited by
    #1

    Hi, I have the following code to check if the user is_administrator then show the two menu items, otherwise of course it won't show... kindly simple! but the problem is.... when I uploaded the pages to my web host, even if the user is not administrator the menu items are shown! the value for is_administrator in MySQL is a bit = 0 but when I do a var_dump I get bool(true) although I get the correct var_dump and behavior on my local pc string(1) "0" this is the menu items:

    <button id="btnManageUsers" type="button" style="width: 100%;">Manage Users</button>
    <button id="btnNewUser" type="button" style="width: 100%;">New User</button>

    and this is the is_administrator:

    while ($mysql_row = $mysql_query->fetch())
    {
    $_SESSION["blended_learning_user_name"] = $mysql_row["user_name"];
    $_SESSION["blended_learning_is_administrator"] = $mysql_row["is_administrator"];

    exit(header("Location: " . $\_SESSION\["blended\_learning\_domain\_name"\] . "mypage"));
    

    }

    Technology News @ www.JassimRahma.com

    V D 2 Replies Last reply
    0
    • J Jassim Rahma

      Hi, I have the following code to check if the user is_administrator then show the two menu items, otherwise of course it won't show... kindly simple! but the problem is.... when I uploaded the pages to my web host, even if the user is not administrator the menu items are shown! the value for is_administrator in MySQL is a bit = 0 but when I do a var_dump I get bool(true) although I get the correct var_dump and behavior on my local pc string(1) "0" this is the menu items:

      <button id="btnManageUsers" type="button" style="width: 100%;">Manage Users</button>
      <button id="btnNewUser" type="button" style="width: 100%;">New User</button>

      and this is the is_administrator:

      while ($mysql_row = $mysql_query->fetch())
      {
      $_SESSION["blended_learning_user_name"] = $mysql_row["user_name"];
      $_SESSION["blended_learning_is_administrator"] = $mysql_row["is_administrator"];

      exit(header("Location: " . $\_SESSION\["blended\_learning\_domain\_name"\] . "mypage"));
      

      }

      Technology News @ www.JassimRahma.com

      V Offline
      V Offline
      vbmike
      wrote on last edited by
      #2

      I think you need to use the '==' double equals sign to check for equality. One equals sign will assign the value to the variable.

      vbmike

      1 Reply Last reply
      0
      • J Jassim Rahma

        Hi, I have the following code to check if the user is_administrator then show the two menu items, otherwise of course it won't show... kindly simple! but the problem is.... when I uploaded the pages to my web host, even if the user is not administrator the menu items are shown! the value for is_administrator in MySQL is a bit = 0 but when I do a var_dump I get bool(true) although I get the correct var_dump and behavior on my local pc string(1) "0" this is the menu items:

        <button id="btnManageUsers" type="button" style="width: 100%;">Manage Users</button>
        <button id="btnNewUser" type="button" style="width: 100%;">New User</button>

        and this is the is_administrator:

        while ($mysql_row = $mysql_query->fetch())
        {
        $_SESSION["blended_learning_user_name"] = $mysql_row["user_name"];
        $_SESSION["blended_learning_is_administrator"] = $mysql_row["is_administrator"];

        exit(header("Location: " . $\_SESSION\["blended\_learning\_domain\_name"\] . "mypage"));
        

        }

        Technology News @ www.JassimRahma.com

        D Offline
        D Offline
        Daniel Lieberwirth BrainInBlack
        wrote on last edited by
        #3

        Well, your problem is that you assign the value true to $_SESSION["blabla"]. I.e. it cannot work! SolutionA:

        SolutionB:

        The difference between SolutionA and B is, that B also checks if $_SESSION["bla"] is of the same type as true, i.e. bool/boolean.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups