Help: Warning: mysqli_num_rows() expects Parameter 1 to be mysqli_result, Boolean Given in C: xampp htdocs redesocial login.php on line 7

Asked

Viewed 1,745 times

-1

<?php
    include("db.php");
    if (isset($_POST['entrar'])) {
        $email = $_POST['email'];
        $pass = $_POST['pass'];
        $verifica = mysqli_query($connect, "SELECT * FROM users WHERE 
email = '$email' AND pass='$pass'");
        if (mysqli_num_rows($verifica)<=0) {
            echo "<h3>A senha ou o e-mail tão torto aí heinKK!</h3>";
        } else {
            setcookie("login",$email);
            header("Location: ./");
        }

    }
?>

I’m trying to create a social network as a form of learning and experience in PHP and MYSQL.

The error that appears is:

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, 
 boolean given in C:\xampp\htdocs\redesocial\login.php on line 7

I’ve tried to get in line if the following argument:

if (!verifica || mysqli_num_rows($verifica)<=0) {}

However, when you click on the login button, it seems that the email and password are not being checked in the database since it simply "logs in" even with the empty login and pass boxes.

2 answers

0

I’ve solved the problem.

As the friend there said, add the or die(mysqli_error($connect)); at the end of the line of the $check variable. However, it returned the error Unknown column 'pass' in 'Where clause'. The name of the pass column was password, that’s all msm. Thank you all :)

0

Query did not return result because it is missing simple quotes between parameters

Example:

$result = mysqli_query($connected,"select * from usuarios Where username = '" . $_SESSION['login_user'] . " ' and password = '" . $_SESSION['login_pass']."' ");

Att,

  • I don’t understand very well, it has to be clearer by kindness? :)

  • I tried so: $verifies = mysqli_query($connect, "SELECT * FROM users WHERE $_POST['email'] = '$email'"" AND $_POST['pass'] = '$pass'"); But returns error: Parse error: syntax error, Unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting '-' or Identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in

Browser other questions tagged

You are not signed in. Login or sign up in order to post.