php mail if statements

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.

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 = "

Thank You For Registering


"; if ($row_email['ins_dep'] = "ins") { $message .=""; } else { $message .=""; } $message .="
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


both if/else statements result in just the if showing every time regardless of the query. Any help would be appreciated.

your have the wrong format for your if statements:
if ($row_email[‘ins_dep’] = “ins”) [/php]

that’s assinging the value of ins to the array item $row_email[‘ins_dep’] you need to compare == instead of assigning:

[php]if ($row_email[‘ins_dep’] == “ins”) [/php]

that did it, thanks a ton. I was stumped.

it’s always the tiniest things that are hard to spot, sometimes just takes another set of eyes :slight_smile:

Sponsor our Newsletter | Privacy Policy | Terms of Service