I have a simple question, which I can't seem to find the correct anwser. I am doing some query to a database to verify that the email that the user is trying to insert doesn't exist.
So I query the database and expect no result, if there is no result, I insert, else I send a message to the user. The problem that I have is: How do I verify that there is no record and don't have a warning in my browser?
Here is a piece of code :
#======================
# RUN QUERY
#======================
function execute ($p_query,$p_debug)
{
$this->query_result = mysql_query($p_query);
if ((mysql_num_rows($this->query_result) < 1 ) && $p_debug == true)
{
echo "Error: No result were found for the query" . mysql_error();
exit;
}
elseif (mysql_num_rows($this->query_result) < 1)
return false;
else
return $this->query_result;
}
If I verify like : if($result), I was reading, in this doc : http://ca2.php.net/manual/en/function.mysql-query.php that it will only return false if the query is invalid, which in my case the query is valid, but I just don't have result.
So how do I verify that the query return no result without getting a Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource to the browser?
Thanks for the help