title: How to get number of rows returned by an SQL select query?
body: <p>I would like to get the number of lines returned by a select query in PHP. I have the following code:</p>
  <pre><code>$connection = new mysqli($server_name, $server_login, $server_password, $dbName);
  
  if (!$connection) {
      echo &quot;error&quot;;
      die(&quot;Connection failed. &quot;.mysqli_connect_error())
  }
  
  //...
  
  $command = &quot;SELECT player_id FROM Player WHERE player_login = '&quot; . $login.&quot;' AND player_password= '&quot;.$password.&quot;' &quot;;
  
  $result = mysqli_query($connection, $command);
  echo num_rows($result);
  </code></pre>
  <p>I also tried with <code>mysqli_stmt_num_rows()</code> and <code>mysqli_num_rows()</code> but my result is always null (no result actually).</p>
  <p>Do you know why?</p>