Fatal error: Uncaught TypeError: mysqli_num_rows(): Argument #1 ($result) must be of type mysqli_result, bool given & Stack trace:#0 & mysqli_num_rows

Viewed 18

How to solve this type of error and please help me to fix this error and i use this php code for my flutter web application for login page & it didn't connect to the DB for my Flutter web application.

This below error is shown when the "login.php" file is run from the php-mysql(xampp) server. i.e., xampp/htdocs/..

Pls observe the below screenshot also...

  • Fatal error: Uncaught TypeError: mysqli_num_rows(): Argument #1 ($result) must be of type mysqli_result, bool given in C:\xampp\htdocs\login\login.php:11 Stack trace: #0 C:\xampp\htdocs\login\login.php(11): mysqli_num_rows(false) #1 {main} thrown in C:\xampp\htdocs\login\login.php on line 11.

    Here is the exact screenshot

login.php :

<?php

    $db = mysqli_connect('localhost','root','','login');

    $email = $_POST['email'];
    $password = $_POST['password'];

    $sql = "SELECT * FROM login WHERE email = '".$email."' AND password = '".$password."'";
    $result = mysqli_query($db, $sql);
    $count = mysqli_num_rows($result);

    if($count == 1) {       //if($count >= 1) {
        echo json_encode("Success..! ");
    }
    else {
        echo json_encode("Error..! ☹");
    }

?>
0 Answers
Related