Hi,
I want to return a variable $count from a function. This will be -1 when database failures occur, else the count(*) of the query. I thought the following would work but no matter what I do -1 is always returned. I did not think that if blocks have local var scope?
function isEmailAllocatedToProfile($email) {
$count = -1;
$connection = mysql_connect($DB_HOST, $DB_USER, $DB_PASS);
if ($connection) {
mysql_select_db($DB_DATA, $connection);
$result = mysql_query("
SELECT COUNT(*) FROM hm_candidates WHERE cand_email = '" . strtolower($email) . "'"
);
if ($result) {
$count = mysql_result($result, 0);
mysql_free_result($result);
}
mysql_close($connection);
}
return $count;
}