Kamikaza Kamikaza - 4 months ago 7
MySQL Question

Error making me crazy - WARNING: MYSQLI_NUM_ROWS() EXPECTS PARAMETER 1 TO BE MYSQLI_RESULT, INTEGER

I cannot fix the follow signup form, it is a basic form, but it show error, the user get saved with password and everything but I keep getting the follow error and cannot find where the error is

<?php
$locatario = mysqli_real_escape_string($database,$_POST['usuario']);
$seguridad = mysqli_real_escape_string($database,$_POST['clave']);
$privilegio = mysqli_real_escape_string($database,$_POST['tipo']);
$revisar = mysqli_query($database, "SELECT locatario FROM locatarios
WHERE locatario = '$locatario'");
$existencia=mysqli_num_rows($revisar);
if(mysqli_num_rows($existencia)>0){
echo "The username is taken";
}else{
$criptologia = hash('sha256', $seguridad);
function createSalt(){$metodo = md5(uniqid(rand(), true));return substr($metodo, 0, 14);}
$codificar = createSalt();
$transformar = hash('sha256', $codificar . $criptologia);
$insertar = mysqli_query($database, "INSERT
INTO `locatarios` VALUES ('', '$locatario', 'Nombre',
'$transformar', '$codificar', '$privilegio')");
{echo "Now you are a new member";}
}
?>

Answer

You input an integer in to mysqli_num_rows on following line

if(mysqli_num_rows($existencia)>0){

replace it with

if(mysqli_num_rows($revisar)>0){

Once you do that delete $existencia=mysqli_num_rows($revisar); line, since its redundant

Comments