I have a cronjob that runs a php page. It checks the database and pulls a result then sends an email, but for some reason I can’t get a couple if / else statements to work. Here’s a code snippet.
[code]
mysql_select_db($database_legacy, $legacy);
$query_email = “SELECT * FROM registration WHERE reg_emailed = ‘N’”;
$email = mysql_query($query_email, $legacy) or die(mysql_error());
$row_email = mysql_fetch_assoc($email);
$totalRows_email = mysql_num_rows($email);
// message
$message = "
".$row_email['realname'].",
Secured with your ".$row_email['card_type']." exp ".$row_email['card_mon']."/".$row_email['card_year']." |
You selected the $45 Property Insurance |
You selected the $300 Security Deposit |
Thank you for pre-registering
";
if ($row_email[‘directions’] = “email”) {
$message .=“You requested to have your directions emailed to you so you can go direct to your vacation home.”;
}
else {
$message .=“You requested to checkin at the self checkin center.”;
}
$message .="
// To send HTML mail, the Content-type header must be set
$headers = ‘MIME-Version: 1.0’ . “\r\n”;
$headers .= ‘Content-type: text/html; charset=iso-8859-1’ . “\r\n”;
// Additional headers
$headers .= ‘From: Me [email protected]’ . “\r\n”;
$headers .= ‘Bcc: [email protected]’ . “\r\n”;
if ($totalRows_email > 0) {
mail($row_email[‘email’], “Thank you for registering”, $message, $headers);
mysql_query(“UPDATE registration SET reg_emailed = ‘Y’ WHERE reg_emailed = ‘N’”);
}// Show if recordset not empty
mysql_free_result($email);
?>[/code]
both if/else statements result in just the if showing every time regardless of the query. Any help would be appreciated.