title: Fatal error: Call to a member function query() on boolean
body: <p>I'm writing a simple database to practice, but I keep getting this error:</p>
  
  <blockquote>
    <p>Fatal error: Call to a member function query() on boolean in
    /Applications/XAMPP/xamppfiles/htdocs/index.php on line 43</p>
  </blockquote>
  
  <p>The query line is line 43, but I can't figure why it's a boolean as neither <code>$conn</code> or <code>$db_handle</code> is <code>false</code>, why is this?</p>
  
  <pre><code>    &lt;?php
  
      $server = "localhost";
      $database = "motocross_db";
      $username = "root";
      $password = "";
  
      $conn = new mysqli($server, $username, $password);
      $db_handle = $conn-&gt;select_db($database);
  
      if ($db_handle)
      {
          if ($_SERVER['REQUEST_METHOD'] == 'POST')
          {
              // upload
          }
  
          $enrollments_sql = "SELECT
                                 users.first_name,
                                 users.last_name,
                                 registrations.attendance_date,
                                 registrations.attendance_location,
                                 bikes.bike_brand,
                                 bikes.engine_size,
                                 bikes.bike_type
                          FROM users
                          INNER JOIN registrations
                             ON users.user_id = registrations.user_id
                          INNER JOIN bikes
                             ON registrations.bike_id = bikes.bike_id";
  
          $enrollments_result = $db_handle-&gt;query($enrollments_sql);
      ?&gt;
  </code></pre>