Hello I am a complete beginner and I'm currently tryin to create an admin login page but it gives me this error
"Fatal error: Uncaught TypeError: mysqli_num_rows(): Argument #1 ($result) must be of type mysqli_result, bool given in C:\xampp\htdocs\hotelreservation\admin.php:48 Stack trace: #0 C:\xampp\htdocs\hotelreservation\admin.php(48): mysqli_num_rows(false) #1 {main} thrown in C:\xampp\htdocs\hotelreservation\admin.php on line 48"
and I don't know how to fix this please help me and thanks in advance
 <body>
        
        <div class = "header">
            <h1> Only Admin can login here!</h1>
        </div>
        
        <div class = "form-design">
            <form method = "POST" action = "">
        
        <div class = "info"
            <label> Username: </label><br>
            <input type = "text" name = "user" required><br>  
            <label> Password: </label><br>
            <input type = "password" name = "pass" required ><br>
            <input type = "submit" name = "login" value = "login"><br>
        </div>
        
            </form>
        </div>
        <a href = "dashboard.php"> Return to dashboard</a>
        
        <?php
        
            session_start();
            
            $connect = mysqli_connect('localhost', 'root', '');
            
            $db = mysqli_select_db($connect, 'admin');
            
                if(isset($_POST['login'])){
                    
                    $username = $_POST['user'];
                    $password = $_POST['pass'];
                    
                        $sql = "SELECT * FROM admin_user WHERE user = '$username' and pass = '$password'";
                        
                        $query = mysqli_query($connect, $sql);
                        $row = mysqli_num_rows($query);
                        
                        if($row['username'] == $username && $row['password'] == $password){
                            echo "login success";
                            $_SESSION['user'] = $username;
                            header ('location:#');
                        }
                }
        
        
        
        ?>
    </body>
 
    