I have this script that uses cron to automatically run this script everynight and send an email if there are records in the query, however no matter what it always sends an email even if there are no records in the query. I think there is an easy answer but I am not seeing it today. Here is the code, any help is much appreciated.
<?php
mysql_connect("");
mysql_select_db("");
$query = "SELECT * FROM KEYCAD WHERE HOLD LIKE 'Y' AND ACTIVE LIKE 'N' AND FOLLOWUPCONTACT LIKE 'Y'";
$result = mysql_query($query);
if($query){
mail("email address", "MESSAGE,
"From: email\r\n"
."Reply-To: email\r\n"
."X-Mailer: PHP/" . phpversion());
}
?>