antiblock
Elveron
  • Chatbox

    You don't have permission to chat.
    Load More
Sign in to follow this  
Daniel Campos

Warning: Mysql_Num_Rows() Expects Parameter 1 To Be Resource, Boolean Given

1 post in this topic

Olá galera estou tentando criar um sistema de login e me apareceu o seguinte erro : Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/andreneder/www/daniel/cadastro.php on line 56.

 

Eu consigo cadastrar mais este erro fica aparecendo e eu queria resolve-lo e não só ocultar. vou colocar aqui em baixo o que escrevi . Ajudem-me

 

<?php

require_once "config.php"
?><html>
<head>
<meta http-equiv="Content-Type" content="text/html, charset=utf-8">
<title>CADASTRO</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
 
<div id="cadastro">
<form method="post" action="?go=cadastrar">
<table id="cad_table">
<tr>
<td>Nome:</td>
<td><input type="text" name="nome" id="nome" class="txt" /></td>
</tr>
<tr>
<td>Email:</td>
<td><input type="text" name="email" id="email" class="txt" /></td>
</tr>
   <tr>
<td>Usuário:</td>
<td><input type="text" name="usuario" id="usuario" class="txt" maxlenght="15" /></td>
</tr>
<tr>
<td>Senha:</td>
<td><input type="password" name="senha" id="senha" class="txt" maxlenght="15" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="Cadastrar" id="btnCad"></td>
</tr>
</table>
</form>
</div>
 
</body>
</html>
 
<?php
if (@$_GET['go'] == 'cadastrar'){
$nome = $_POST['nome'];
$email = $_POST['email'];
$user = $_POST['usuário'];
$password = $_POST['senha'];
 
if (empty($nome)){
echo "<script>alert('Preencha todos os campos para se cadastrar.'); history.back();</script>";
}elseif (empty($email)){
echo "<script>alert('Preencha todos os campos para se cadastrar.'); history.back();</script>";
}elseif (empty($usuario)){
echo "<script>alert('Preencha todos os campos para se cadastrar.'); history.back();</script>";
}elseif (empty($senha)){
echo "<script>alert('Preencha todos os campos para se cadastrar.'); history.back();</script>";
}else{
$query1 = mysql_num_rows(mysql_query("SELECT * FROM USUARIO WHERE USUARIO = '$user'"));
if($query1 == 1){   << onde fala que está o erro e aonde está todo vermelho
echo "<script>alert('Usuário já existe.'); history.back();</script>";
}else{
mysql_query("insert into usuario (nome, email, usuario, senha) values ('$nome', '$email', '$user', '$pwd')");
echo "<script>alert('Usuário cadastrado com sucesso.');</script>";
 
 
}
 
}
 
}
 
?>

Share this post


Link to post
Share on other sites
antiblock
Elveron

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this