[insert_php]

include ‘events.php’;

$subject = ‘URGENT – BBM Run Pass Picture Upload REQUIRED’;

$emailQuery = “select FirstName, LastName, UserID, Email from ds_event_registration_scanning where UserPicture = ” AND Email != ‘REFUNDED’ AND Email != ” AND UserID = ‘999999’; “;
$result = mysql_query($emailQuery);
$emailCount = 0;

if (!$result) {
// the query failed, return an error
echo “There was an error retrieving the query results. Messages could not be sent.”;
$emailCount = ‘n’;
} // if result
else {
if (mysql_num_rows($result) == 0) {
// the query ran but returned no results, return error
echo “There were no rows returned from the query results indicating there are no new users to be contacted. 0 Messages sent.”;
} // if mysql_num_rows
else {
// query completed and rows returned, load into array and return values
while ($row= mysql_fetch_assoc($result)) {
$emailName = $row[‘FirstName’] . ” ” . $row[‘LastName’];
$emailAddress = $row[‘Email’];
$userID = $row[‘UserID’];
$photoURL = “www.bearsbikersandmayhem.com/event/profile-picture/?profileID=” . $userID;
$headers = “From: [email protected]\r\n”;
$headers .=”Reply-To: [email protected]\r\n”;
$headers .= “MIME-Version: 1.0\r\n”;
$headers .= “Content-type: text/html; charset=ISO-8859-1\r\n”;
$message = “”;
$message = ”
\"Bears,

Hello ” . $emailName . “!

This is a reminder that this year for Bears Bikers and Mayhem we have a feature which allows you to post a profile picture that will be printed on your badge. This badge will get you access to all of our events! We’ve noticed you have not uploaded a profile picture yet. If you follow the link you can upload a photo from your phone camera or from a file on your phone or computer. You can upload or modify your profile picture by using the following link:

(URL Text: ” . $photoURL . ” )

You can check to make sure your photo uploaded, or change the photo by following the link. If you have any trouble, please reply to this email and attach your photo for us to upload for you.

Thanks and we look forward to seeing you soon!

The Bears Bikers and Mayhem Team

“;

$to = $emailAddress;
//mail($to, $subject, $message, $headers);

$emailCount++;
/*
$sentEmailQuery = “Update ds_event_registration_scanning set picEmailSent = ‘y’ where UserID = ‘” . $userID . “‘;”;
if (!submitQuery($sentEmailQuery)) {
echo “Could not update database for email sent notification.”;
}
*/
} //while
} // else mysql_num_rows
} // else if result

if ($emailCount != ‘n’) {
echo “Emails completed. There were ” . $emailCount . ” emails sent.”;
}

if (!$mysqli->query(“CALL addEmailEventUsage(” . $emailCount . “);”)) {
echo “Event Usage CALL failed: (” . $mysqli->errno . “) ” . $mysqli->error;
}
else {
mysql_free_result();
}

[/insert_php]