Jump to content

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean give


jose

Recommended Posts

When I run the program above I get this message

 

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\Program Files\xampp\htdocs\entrepreneurs\Sign_Up.php on line 27

 

I reviewed some similar problems resolved but unfortunately I cannot apply to my case.  Anybody have any idea about the solution?

 

Thanks

 

 

<?php

 

  require_once('connectvars.php');

 

  // Connect to the database

  $dbc = mysqli_connect('localhost', 'root', 'zambullo', 'entrepreneurial groups')

    or die ('Error connecting to MySQL server');

 

  if (isset($_POST['submit'])) {

    // Grab the profile data from the POST

    $username = mysqli_real_escape_string($dbc, trim($_POST['username']));

    $password = mysqli_real_escape_string($dbc, trim($_POST['password']));

    $repeatpassword = mysqli_real_escape_string($dbc, trim($_POST['repeatpassword']));

 

    if (!empty($username) && !empty($password) && !empty($repeatpassword) && ($password == $repeatpassword)) {

      // Make sure someone isn't already registered using this username

      $query = "SELECT * FROM Entrepreneurialgroups_user WHERE username = '$username'";

      $data = mysqli_query($dbc, $query);

      if (mysqli_num_rows($data) == 0) {

        // The username is unique, so insert the data into the database

        $query = "INSERT INTO entrepreneurialgroups _user (username, password, join_date) VALUES ('$username', SHA('$password'), NOW())";

        mysqli_query($dbc, $query);

 

        // Confirm success with the user

        echo '<p>Your new account has been successfully created. You\'re now ready to <a href="login.php">log in</a>.</p>';

 

        mysqli_close($dbc);

        exit();

      }

      else {

        // An account already exists for this username, so display an error message

        echo '<p class="error">An account already exists for this username. Please use a different address.</p>';

        $username = "";

      }

    }

    else {

      echo '<p class="error">You must enter all of the sign-up data, including the desired password twice.</p>';

    }

  }

 

  mysqli_close($dbc);

?>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.