jose Posted April 20, 2010 Share Posted April 20, 2010 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); ?> Link to comment https://forums.phpfreaks.com/topic/199099-warning-mysqli_num_rows-expects-parameter-1-to-be-mysqli_result-boolean-give/ Share on other sites More sharing options...
ChemicalBliss Posted April 20, 2010 Share Posted April 20, 2010 There is no default function called mysqli_num_rows(). http://php.net/mysqli_num_rows I would reccommend using mysqli in OO syntax rather than procedural. eg: $data->num_rows(); -cb- Link to comment https://forums.phpfreaks.com/topic/199099-warning-mysqli_num_rows-expects-parameter-1-to-be-mysqli_result-boolean-give/#findComment-1045027 Share on other sites More sharing options...
jose Posted April 20, 2010 Author Share Posted April 20, 2010 Great, cb I changed procedural for OO following your suggestions and IT WORKS!! Thanks a lot Jose Link to comment https://forums.phpfreaks.com/topic/199099-warning-mysqli_num_rows-expects-parameter-1-to-be-mysqli_result-boolean-give/#findComment-1045173 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.