This question already has an answer here:
I'm making an user register system with PHP and MySQL. The problem is when I try to verify if the user is already registered I get the following error:
mysql_num_rows() expects parameter 1 to be resource, boolean given
This is my code:
$sql = mysql_query("SELECT identificacion FROM cliente WHERE identificacion='".$usuario_dni."'");
if(mysql_num_rows($sql) > 0) {
echo "Esta identificacion ya ha sido utilizada en un registro anteriormente. <a href='javascript:history.back();'>Reintentar</a>";
}else {
//$usuario_clave = md5($usuario_clave); // Encriptamos la contraseña
$reg = mysql_query("INSERT INTO cliente VALUES ('".$usuario_nombre."', '".$usuario_apellidos."', '".$usuario_dni."', '".$usuario_fecha."', '"
.$usuario_tlfn."', '".$usuario_pais."' ,".$usuario_email."', NOW())");
if($reg) {
echo "Usuario Registrado con exito.";
}else {
echo "Ha ocurrido un error y no se ha podido registrar.";
}
</div>