I working on how to check if value already exist in a database. Whenever I try to input something (Example: 000) there's always an error: Warning: mysql_num_rows() expects parameter 1 to be resource..., but the input was saved in the database
then if I input the same again, the condition to check if value exist doesn't work
if (isset($_POST['add']))
{
$docid = $_POST['docid'];
$check = mysql_query("SELECT doc.docid, doc_details.docid FROM doc, doc_details WHERE docid='$docid'");
$number_of_rows = mysql_num_rows($check);
if ($number_of_rows > 0)
{
echo "<script> alert('Your input already exist, no input made'); </script>";
}
else
{
$insert = mysql_query("INSERT INTO doc (docid) VALUES ('$docid')");
$insert = mysql_query("INSERT INTO doc_details (docid) VALUES ('$docid')");
echo "<script> alert('ADDING: Successful'); </script>";
}
}