title: PHP & MYSQL: Select from where id=$id
body: <p>So I'm making a usergroup function that allows me to block off pages to lower user levels. This is my function for grabbing info:</p>
  
  <pre><code>function grab_info($id, $requested_info){
      $id = $_SESSION['user_id'];
      $requested_info = $requested_info;
      $con = new mysqli('localhost', 'root', '', 'login');
      if ($con-&gt;connect_errno &gt;0){
          die("Handle your connection error here");
      }
      $sql = "SELECT * FROM `users` WHERE `id` = $id";
      if (!$result = $con-&gt;query($sql)) {
          die("There as a query error for some reason handle your query error");
      }
      while($row = $result-fetch_assoc()){
          $info = $row[$requested_info];
          return $info;
      }
  }
  </code></pre>
  
  <p>Right here: </p>
  
  <pre><code>$sql = "SELECT * FROM `users` WHERE `id` = $id";
  if (!$result = $con-&gt;query($sql)) {
      die("There as a query error for some reason handle your query error");
  }
  </code></pre>
  
  <p>is where something is going wrong. This is my method for grabbing the info:</p>
  
  <pre><code>$id = $_SESSION['user_id'];
  $rank = grab_info($id, 'rank');//Gets rank from our id
  $meets = can_access($rank, 4, true);//We're saying our user has a rank of 1 to access this page you need a rank of 3 and only 3 hence strict
  if ($meets == false){//user cant access page
      header("Location: index.php");
      die();
  }
  </code></pre>
  
  <p>Basically, it just keeps giving me the "There as a query error for some reason handle your query error" and I'm stuck. New to php so sorry if it's messy.</p>