Clinton Posted April 24, 2008 Share Posted April 24, 2008 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) $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'); ///////////////////////Mail Starts Here////////////////////////// $subject = "Weekly 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>"; } } ///////////////// Mail Finishes Here ///////////////////////// This is an automated response, please do not reply!"; mail(([email protected],[email protected]), $subject, $message, "From: NorthAmerican Services Group<[email protected]>\n X-Mailer: PHP/" . phpversion()); ?> Link to comment https://forums.phpfreaks.com/topic/102789-solved-mail-help/ Share on other sites More sharing options...
Spaceman-Spiff Posted April 24, 2008 Share Posted April 24, 2008 Syntax error here: $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>"; You didn't close the quote sign in $message Link to comment https://forums.phpfreaks.com/topic/102789-solved-mail-help/#findComment-526523 Share on other sites More sharing options...
Clinton Posted April 24, 2008 Author Share Posted April 24, 2008 That's not it. I had it opened at the top and closed at the bottom. I went through and took out all the <? ?> around php and now it works.... BUT it doesn't parse. It shows the actual code, not the results. :-| Link to comment https://forums.phpfreaks.com/topic/102789-solved-mail-help/#findComment-526547 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.