Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9157131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:56:18+00:00 2026-06-17T12:56:18+00:00

i have already searched everywhere but could not find a solution for the problem.

  • 0

i have already searched everywhere but could not find a solution for the problem.
i have a login script in php.When there are no matches in the database for user entered values, an error message is displayed.But also another warning is being thrown.

Warning: mysqli_num_rows() expects parameter 1 to be mysqli, 
boolean given in C:\xampp\htdocs\index.php on line 26

Here’s the code. i know that a similar question has been asked many times,but none of them could provide me the solution.Here’s the entire code.

    <?php

    session_start();
    require_once('connectionvariables.php');
    $error_msg = "";

    if(!isset($_SESSION['user_id']))
     {
      if(!empty($_COOKIE['user_id']) && !empty($_COOKIE['username']))
        {
          $_SESSION['user_id'] = $_COOKIE['user_id'];
          $_SESSION['username'] = $_COOKIE['username'];
     }
     else
      {
        if(isset($_POST['submit']))
         {
          $dbc = mysqli_connect(DB_HOST,DB_USER,DB_PASSWORD,DB_NAME);
        $user_username = mysqli_real_escape_string($dbc,trim($_POST['username']));
        $user_password = mysqli_real_escape_string($dbc,trim($_POST['password']));

        if(!empty($user_username) && !empty($user_password))
        {
            $query = "SELECT user_id,username FROM mismatch_user WHERE username =       '$user_username' AND password = SHA('$user_password')";
            $data = mysqli_query($dbc,$query); 
            if(mysqli_num_rows($data) == 1)
            {
                $row = mysqli_fetch_array($data);
                $_SESSION['user_id'] = $row['user_id'];
                $_SESSION['username'] = $row['username'];
                setcookie('user_id',$row['user_id'],time() + ( 60 * 60 * 3600));
                setcookie('username',$row['username'],time() + ( 60 * 60 * 3600));
                header('Location: http://www.google.com');    

            }
            else
            {
                $error_msg = 'enter a valid username and password';
            }
        }
        else
        {
            $error_msg = 'you have to enter username and password to Log In...';
        }
    }
   }
}
?>

Here’s the line 26.

if(mysqli_num_rows($data) == 1)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:56:20+00:00Added an answer on June 17, 2026 at 12:56 pm

    There is likely an error in your query. For example, an unknown column name or similar issue will let mysqli_query return false (a boolean). I suggest you double check your query’s contents to fix any typo. See http://php.net/manual/en/mysqli.query.php for more details.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have already searched through SO and could not fins a workable solution for
I have already googled and searched stackoverflow but I can find nothing related to
I have already surveyed SO for an answer, and could not find an appropriate
I have already searched all day for a solution. Unfortunately, have not found anything
Okay, so I have searched a while for a solution to this problem, but
I already searched a long time for a good solution, but I can't find
I'm having a problem, which already searched the internet but can not solve. I
I searched everywhere, but without finding any solution. The problem is: I'm trying to
I've searched for the solution for this everywhere and have not found an answer,
I have already read some posts, but no one helped me with my problem.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.