Hola soy nuevo en todo esto pero de a poco voy aprendiendo como todos. me salio el siguiente error y no se como solucionarlo, e buscado en internet el mismo error y sale pero en distintos casos que el mio.
es un simple script de registrar. y al momento de registrarse alguna persona sale este error
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /www/clanteam.com/c/o/m/comparte/htdocs/regcheck.php on line 52
este es el codigo:
<?php
if(
isset( $_POST['user'] ) &&
isset( $_POST['pass'] )
)
{
if( strlen( $_POST['user'] ) < 4 )
{
echo "Username Must Be More Than 4 Characters.";
}
elseif( strlen( $_POST['pass'] ) < 4 )
{
echo "Passwrod Must Be More Than 4 Characters.";
}
elseif( $_POST['pass'] == $_POST['user'] )
{
echo"Username And Password Can Not Be The Same.";
}
else
{
include( 'database.php' );
$username = mysql_real_escape_string( $_POST['user'] );
$password = md5( $_POST['pass'] );
$sqlCheckForDuplicate = "SELECT username FROM user WHERE username = '". $username
."'";
if( mysql_num_rows( mysql_query( $sqlCheckForDuplicate ) ) == 0 )
{
$sqlRegUser = "INSERT INTO
user( username, password )
VALUES(
'". $username ."',
'". $password ."'
)";
if( !mysql_query( $sqlRegUser ) )
{
echo "You Could Not Register Because Of An Unexpected Error.";
}
else
{
echo "You Are Registered And Can Now Login";
$formUsername = $username;
header ('location: Login.php');
}
}
else
{
echo "The Username You Have Chosen Is Already Being Used By Another User. Please Try Another
One.";
$formUsername = $username;
}
}
}
else
{
echo "You Could Not Be Registered Because Of Missing Data.";
}
?>
espero que me puedan ayudar