title: I want MySQL to return a number but instead it returns a table
body: <p>I am trying to use this code:</p>
  
  <pre class="lang-php prettyprint-override"><code>$servername = "localhost";
  $username = "[censored]";
  $password = "[censored]";
  $dbname = "[censored]";
  
  // Create connection
  $conn = new mysqli($servername, $username, $password, $dbname);
  
  // Check connection
  if ($conn-&gt;connect_error) {
      die("disconnected");
  }
  
  $secret_token = sha1(rand(1,9999999999));
  $sql = "SELECT COUNT(username) FROM `sessions` WHERE username = 'isOnline4'";
  echo $conn-&gt;query($sql);
  
  if ($conn-&gt;query($sql) == 1) {
      echo "I am fairly sure you already have a secret token boi!";
      die;
  } else {
      echo "Nope";
  }
  $conn-&gt;close();
  </code></pre>
  
  <p>And I was under the impression that <code>$conn-&gt;query($sql)</code> would return a number like 1, 2, or 3, but instead it is returning a row. I have tried several different kinds of queries but they all return tables or a table containing a number.</p>