Every time I try to create an account using this script, I get the following error: "Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\registration.php on line 16 Record successfully inserted"
I am trying to check if the account name already exists.
I have done lots of searching around on this website but I can't seem to get this issue figured out.
Here is my code:
<?php
Include 'connect.php';
If(isset($_REQUEST['submit'])!='')
{
If($_REQUEST['Username']=='' || $_REQUEST['Password']=='')
{
Echo "please fill the empty field.";
}
Else
{
$result = mysql_query("SELECT Username FROM accounts WHERE Username = ".$_REQUEST['Username']."");
$sql="insert into accounts(Username,Password) values('".$_REQUEST['Username']."', '".$_REQUEST['Password']."')";
$res=mysql_query($sql);
if(!mysql_num_rows($result) >= 1)
{
Echo "Record successfully inserted";
}
Else
{
Echo "There is some problem in inserting record";
}
}
}
?>