icon Get the most out of Surmunity, read our tips here! Need an interesting blog to read? You've got to read the Surpass Blog! | Welcome! Please register to access all of our features.

» Surpass Web Hosting Forums » Discussions » PHP, MySQL » Mail() Help

PHP, MySQL General PHP questions. Or go to our PHPsuexec Forum >>

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread
Old April 24th, 2008, 5:59 PM   #1 (permalink)
Registered User
Comfy Contributor
 
hunna03's Avatar
 
Joined in Mar 2006
Lives in UT
Hosted on SH92
165 posts
Gave thanks: 28
Thanked 0 times
Red face Mail() Help

Alright, the code below looks harder than it is but really it's just repetitive. I plan on using a cron job to run this daily and I want to e-mail the output to 2 individuals. But when I try to input the whole mail bit it doesn't work. I know it has something to do with setting the $message variable I'm just not sure what to do. The first error I got was : Parse error: syntax error, unexpected '>' on line 20. Help would greatly be appreciated. Thank you. (By the way, everything works just fine until the mail variables were put in)

Code:
$dbhandle = mysql_connect($hostname, $username, $password)
  or die("Unable to connect to MySQL");

$selected = mysql_select_db("clintona_SLC",$dbhandle)
  or die("Can not open SLC Database");

$result = mysql_query("SELECT * FROM training ORDER BY lname");

$nowtrue = date('Y-m-d');

$subject = "Weekly NorthAmerican Training Report!"; 
$message = " 

echo "<center><font size=6 color=blue> Salt Lake City Expiring Training Report </font><br><font color=blue>If nothing is below there are no actions needed.</font></center><p>";

while ($row=mysql_fetch_assoc($result)){ extract($row);

$driverslicense = strtotime($driverslicense.'- 1 month');

$driverslicense = date('Y-m-d',$driverslicense);

$driverslicenseexpire = strtotime($driverslicense.'+ 1 month');

$driverslicenseexpire = date('n/j/Y',$driverslicenseexpire);

if ($nowtrue > $driverslicense) {
	  echo "<center> $fname $lname is due for a Drivers License renewal! It Expires $driverslicenseexpire <p></center>"; 
 			}


$cdlmedicalexpire = strtotime($cdlmedical.'+ 24 months');

$cdlmedicalexpire = date('n/j/Y',$cdlmedicalexpire);

$cdlmedical = strtotime($cdlmedical.'+ 23 months');

$cdlmedical = date('Y-m-d',$cdlmedical);

if ($nowtrue > $cdlmedical) {
	  echo "<center> $fname $lname is due for a CDL Medical Evaluation! It Expires $cdlmedicalexpire <p></center>"; 
 			}


$hazmatmedicalexpire = strtotime($hazmatmedical.'+ 12 months');

$hazmatmedicalexpire = date('n/j/Y',$hazmatmedicalexpire);

$hazmatmedical = strtotime($hazmatmedical.'+ 11 months');

$hazmatmedical = date('Y-m-d',$hazmatmedical);

if ($nowtrue > $hazmatmedical) {
	  echo "<center> $fname $lname is due for a HazMat Medical Evaluation! It Expires $hazmatmedicalexpire <p></center>"; 
 			}


$kucccontractorexpire = strtotime($kucccontractor.'+ 12 months');

$kucccontractorexpire = date('n/j/Y',$kucccontractorexpire);

$kucccontractor = strtotime($kucccontractor.'+ 11 months');

$kucccontractor = date('Y-m-d',$kucccontractor);

if ($nowtrue > $kucccontractor) {
	  echo "<center> $fname $lname is due for KUCC Contractor Orientation! It Expires $kucccontractorexpire <p></center>"; 
 			}

$kuccehsplanexpire = strtotime($kuccehsplan.'+ 12 months');

$kuccehsplanexpire = date('n/j/Y',$kuccehsplanexpire);

$kuccehsplan = strtotime($kuccehsplan.'+ 11 months');

$kuccehsplan = date('Y-m-d',$kuccehsplan);

if ($nowtrue > $kuccehsplan) {
	  echo "<center> $fname $lname is due to renew the KUCC Personal EH & S Plan! It Expires $kuccehsplanexpire <p></center>"; 
 			}

$kuccconcentratorexpire = strtotime($kuccconcentrator.'+ 12 months');

$kuccconcentratorexpire = date('n/j/Y',$kuccconcentratorexpire);

$kuccconcentrator = strtotime($kuccconcentrator.'+ 11 months');

$kuccconcentrator = date('Y-m-d',$kuccconcentrator);

if ($nowtrue > $kuccconcentrator) {
	  echo "<center> $fname $lname is due for the KUCC Hazard Recognition Concentrator Program! It Expires $kuccconcentratorexpire <p></center>"; 
 			}

$kuccmineexpire = strtotime($kuccmine.'+ 12 months');

$kuccmineexpire = date('n/j/Y',$kuccmineexpire);

$kuccmine = strtotime($kuccmine.'+ 11 months');

$kuccmine = date('Y-m-d',$kuccmine);

if ($nowtrue > $kuccmine) {
	  echo "<center> $fname $lname is due for the KUCC Hazard Recognition Mine & Copperton Program! It Expires $kuccmineexpire <p></center>"; 
 			}

$kuccuppexpire = strtotime($kuccupp.'+ 12 months');

$kuccuppexpire = date('n/j/Y',$kuccuppexpire);

$kuccupp = strtotime($kuccupp.'+ 11 months');

$kuccupp = date('Y-m-d',$kuccupp);

if ($nowtrue > $kuccupp) {
	  echo "<center> $fname $lname is due for the KUCC Hazard Recognition UPP Program! It Expires $kuccuppexpire <p></center>"; 
 			}

$kuccpmetalsexpire = strtotime($kuccpmetals.'+ 12 months');

$kuccpmetalsexpire = date('n/j/Y',$kuccpmetalsexpire);

$kuccpmetals = strtotime($kuccpmetals.'+ 11 months');

$kuccpmetals = date('Y-m-d',$kuccpmetals);

if ($nowtrue > $kuccpmetals) {
	  echo "<center> $fname $lname is due for the KUCC Hazard Recognition Precious Metals Program! It Expires $kuccpmetalsexpire <p></center>"; 
 			}

$kuccpitexpire = strtotime($kuccpit.'+ 12 months');

$kuccpitexpire = date('n/j/Y',$kuccpitexpire);

$kuccpit = strtotime($kuccpit.'+ 11 months');

$kuccpit = date('Y-m-d',$kuccpit);

if ($nowtrue > $kuccpit) {
	  echo "<center> $fname $lname is due for the KUCC Pit License! It Expires $kuccpitexpire <p></center>"; 
 			}

$msha46expire = strtotime($msha46.'+ 12 months');

$msha46expire = date('n/j/Y',$msha46expire);

$msha46 = strtotime($msha46.'+ 11 months');

$msha46 = date('Y-m-d',$msha46);

if ($nowtrue > $msha46) {
	  echo "<center> $fname $lname is due for MSHA Part 46 Training! It Expires $msha46expire <p></center>"; 
 			}

$msha48expire = strtotime($msha48.'+ 12 months');

$msha48expire = date('n/j/Y',$msha48expire);

$msha48 = strtotime($msha48.'+ 11 months');

$msha48 = date('Y-m-d',$msha48);

if ($nowtrue > $msha48) {
	  echo "<center> $fname $lname is due for MSHA Part 48 Training! It Expires $msha48expire <p></center>"; 
 			}

$mvrcheckexpire = strtotime($mvrcheck.'+ 12 months');

$mvrcheckexpire = date('n/j/Y',$mvrcheckexpire);

$mvrcheck = strtotime($mvrcheck.'+ 11 months');

$mvrcheck = date('Y-m-d',$mvrcheck);

if ($nowtrue > $mvrcheck) {
	  echo "<center> $fname $lname is due for an MVR Check! It Expires $mvrcheckexpire <p></center>"; 
 			}

$respiratorfitexpire = strtotime($respiratorfit.'+ 12 months');

$respiratorfitexpire = date('n/j/Y',$respiratorfitexpire);

$respiratorfit = strtotime($respiratorfit.'+ 11 months');

$respiratorfit = date('Y-m-d',$respiratorfit);

if ($nowtrue > $respiratorfit) {
	  echo "<center> $fname $lname is due for a Respirator Fit Test! It Expires $respiratorfitexpire <p></center>"; 
 			}

$respiratormedicalexpire = strtotime($respiratormedical.'+ 12 months');

$respiratormedicalexpire = date('n/j/Y',$respiratormedicalexpire);

$respiratormedical = strtotime($respiratormedical.'+ 11 months');

$respiratormedical = date('Y-m-d',$respiratormedical);

if ($nowtrue > $respiratormedical) {
	  echo "<center> $fname $lname is due for a Respirator Medical Evaluation! It Expires $respiratormedicalexpire <p></center>"; 
 			}

$substance9expire = strtotime($substance9.'+ 12 months');

$substance9expire = date('n/j/Y',$substance9expire);

$substance9 = strtotime($substance9.'+ 11 months');

$substance9 = date('Y-m-d',$substance9);

if ($nowtrue > $substance9) {
	  echo "<center> $fname $lname is due for a NIDA 9-Panel Drug Test! It Expires $substance9expire <p></center>"; 
 			}

$naislifttruckexpire = strtotime($naislifttruck.'+ 24 months');

$naislifttruckexpire = date('n/j/Y',$naislifttruckexpire);

$naislifttruck = strtotime($naislifttruck.'+ 23 months');

$naislifttruck = date('Y-m-d',$naislifttruck);

if ($nowtrue > $naislifttruck) {
	  echo "<center> $fname $lname is due for the NAIS Task Training Lift Truck Training! It Expires $naislifttruckexpire <p></center>"; 
 			}

$fmchazexpire = strtotime($fmchaz.'+ 12 months');

$fmchazexpire = date('n/j/Y',$fmchazexpire);

$fmchaz = strtotime($fmchaz.'+ 11 months');

$fmchaz = date('Y-m-d',$fmchaz);

if ($nowtrue > $fmchaz) {
	  echo "<center> $fname $lname is due for FMC Corp. Retraining! It Expires $fmchazexpire <p></center>"; 
 			}

$solvayhazexpire = strtotime($solvayhaz.'+ 12 months');

$solvayhazexpire = date('n/j/Y',$solvayhazexpire);

$solvayhaz = strtotime($solvayhaz.'+ 11 months');

$solvayhaz = date('Y-m-d',$solvayhaz);

if ($nowtrue > $solvayhaz) {
	  echo "<center> $fname $lname is due for Solvay Chemicals Retraining! It Expires $solvayhazexpire <p></center>"; 
 			}

$barrickhazexpire = strtotime($barrickhaz.'+ 12 months');

$barrickhazexpire = date('n/j/Y',$barrickhazexpire);

$barrickhaz = strtotime($barrickhaz.'+ 11 months');

$barrickhaz = date('Y-m-d',$barrickhaz);

if ($nowtrue > $barrickhaz) {
	  echo "<center> $fname $lname is due for Barrick Goldstrike Retraining! It Expires $barrickhazexpire <p></center>"; 
 			}

$uitchazexpire = strtotime($uitchaz.'+ 12 months');

$uitchazexpire = date('n/j/Y',$uitchazexpire);

$uitchaz = strtotime($uitchaz.'+ 11 months');

$uitchaz = date('Y-m-d',$uitchaz);

if ($nowtrue > $uitchaz) {
	  echo "<center> $fname $lname is due for UITC Retraining! It Expires $uitchazexpire <p></center>"; 
 			}

$newmonthazexpire = strtotime($newmonthaz.'+ 12 months');

$newmonthazexpire = date('n/j/Y',$newmonthazexpire);

$newmonthaz = strtotime($newmonthaz.'+ 11 months');

$newmonthaz = date('Y-m-d',$newmonthaz);

if ($nowtrue > $newmonthaz) {
	  echo "<center> $fname $lname is due for Newmont Retraining! It Expires $newmonthazexpire <p></center>"; 
 			}

$genchemhazexpire = strtotime($genchemhaz.'+ 12 months');

$genchemhazexpire = date('n/j/Y',$genchemhazexpire);

$genchemhaz = strtotime($genchemhaz.'+ 11 months');

$genchemhaz = date('Y-m-d',$genchemhaz);

if ($nowtrue > $genchemhaz) {
	  echo "<center> $fname $lname is due for General Chemicals Retraining! It Expires $genchemhazexpire <p></center>"; 
 			}

$hazwoper40expire = strtotime($hazwoper40.'+ 12 months');

$hazwoper40expire = date('n/j/Y',$hazwoper40expire);

$hazwoper40 = strtotime($hazwoper40.'+ 11 months');

$hazwoper40 = date('Y-m-d',$hazwoper40);

if ($nowtrue > $hazwoper40) {
	  echo "<center> $fname $lname is due for 8-Hour Hazwoper Refresher training! It Expires $hazwoper40expire <p></center>"; 
 			}

$hazwoper24expire = strtotime($hazwoper24.'+ 12 months');

$hazwoper24expire = date('n/j/Y',$hazwoper24expire);

$hazwoper24 = strtotime($hazwoper24.'+ 11 months');

$hazwoper24 = date('Y-m-d',$hazwoper24);

if ($nowtrue > $hazwoper24) {
	  echo "<center> $fname $lname is due for 8-Hour Hazwoper Refresher training! It Expires $hazwoper24expire <p></center>"; 
 			}

$firstaidcprexpire = strtotime($firstaidcpr.'+ 12 months');

$firstaidcprexpire = date('n/j/Y',$firstaidcprexpire);

$firstaidcpr = strtotime($firstaidcpr.'+ 11 months');

$firstaidcpr = date('Y-m-d',$firstaidcpr);

if ($nowtrue > $firstaidcpr) {
	  echo "<center> $fname $lname is due for a First-Aid/CPR Refresher Course! It Expires $firstaidcprexpire <p></center>"; 
 			}



}

" echo "This is an automated response, please do not reply!";
mail((binaryblaster@gmail.com,jami_boggs@hotmail.com), $subject, $message,
"From: NorthAmerican Services Group<binaryblaster@gmail.com>\n 
X-Mailer: PHP/" . phpversion()); 
?>

<html>
<head>
<title>Salt Lake City Daily Check</title>

</head>
__________________
~CJA~
72.29.87.117
"Constantly lost in the world of PHP" is my personal understatement.
hunna03 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old April 24th, 2008, 6:37 PM   #2 (permalink)
Surpass Fan
Excelling Contributor
 
cowboy's Avatar
 
Joined in Nov 2005
Lives in Colorado
Hosted on DEDI
936 posts
Gave thanks: 2
Thanked 95 times
Addresses need to be strings.

Either:
Code:
$to = 'binaryblaster@gmail.com';
$to .= ',';
$to .= 'jami_boggs@hotmail.com';
 
mail($to, $subject, $message,
"From: NorthAmerican Services Group<binaryblaster@gmail.com>\r\n 
X-Mailer: PHP/" . phpversion()); 
or:

Code:
mail('binaryblaster@gmail.com,jami_boggs@hotmail.com', $subject, $message,
"From: NorthAmerican Services Group<binaryblaster@gmail.com>\r\n 
X-Mailer: PHP/" . phpversion()); 
__________________
Where would you be if you were at the highest court in the land (US)?
cowboy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old April 24th, 2008, 7:05 PM   #3 (permalink)
Registered User
Comfy Contributor
 
hunna03's Avatar
 
Joined in Mar 2006
Lives in UT
Hosted on SH92
165 posts
Gave thanks: 28
Thanked 0 times
Smile

Thanks.
__________________
~CJA~
72.29.87.117
"Constantly lost in the world of PHP" is my personal understatement.
hunna03 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old April 24th, 2008, 7:39 PM   #4 (permalink)
Registered User
Comfy Contributor
 
hunna03's Avatar
 
Joined in Mar 2006
Lives in UT
Hosted on SH92
165 posts
Gave thanks: 28
Thanked 0 times
If I do this would I get the HTML formatting if I ran the CRON? I just took out the whole mail stuff and just used the default Cron Mail feature but it outputs in non-html and overall makes it harder to read.
__________________
~CJA~
72.29.87.117
"Constantly lost in the world of PHP" is my personal understatement.
hunna03 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On