neilw_uk Posted April 19, 2008 Share Posted April 19, 2008 Hi, I'm trying to add some additional info to an email sent from our website which pulls info from an database. As it stands without what i want to add it works fine; however when i try to add my bit of html it all goes wrong!!! Most of the original email comes through but non of the html code i add is displayed in the email. The working code is: <? include "inc/global.php"; ?> <? #Configure PHP Mailer require_once("class.phpmailer.php"); $mail = new PHPMailer(); $mail->SetLanguage( 'en', '/usr/lib/php/language/' ); $mail->IsSMTP(); // send via SMTP $mail->Host = "relay.myisp.net"; // SMTP servers $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = "accountpop3.domain.co.uk"; // SMTP username $mail->Password = "password"; // SMTP password $mail->IsHTML(true); $mail->Sender = "[email protected]"; $mail->From = "[email protected]"; $mail->FromName = "Management"; $mail->AddReplyTo("[email protected]"); $query = mysql_query("select * from flights where flight_id = '$id'"); $data = mysql_fetch_array($query); $query2 = mysql_query("select * from launch_site where launch_id = '$data[site]'"); $data2 = mysql_fetch_array($query2); $query3 = mysql_query("select * from balloons where balloon_id = '$data[balloon_code]'"); $data3 = mysql_fetch_array($query3); ?> <? $dat = explode("-", $data[date]); ?> <? $from = "[email protected]"; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "From: ".$from."\r\n"; $headers .= "Return-Path: ".$from."\r\n"; $addit_param="-f".$from; $pioltq = mysql_query("select * from pilots where pilot_id='$data[pilot_id]'"); $pilot = mysql_fetch_array($pioltq); $to = $pilot[email]; $message = "<html><body style='font-family:Arial, Helvetica, sans-serif'><table align=\"center\" width=\"100%\"> <tr> <td align=\"center\"> <font size=\"+2\"> <strong>Pilot List - Passengers to Fly on $dat[2]-$dat[1]-$dat[0] from $data2[location]</strong> </font> </td> </tr> <tr> <td align=\"center\"> <strong>$dat[2]-$dat[1]-$dat[0]</strong> <strong>$data[am_pm]</strong> <strong>$data3[code]</strong> </td> </tr> <tr> <td> <table width=\"100%\"> <tr valign=\"top\"> <td colspan=\"3\"> <table align=\"center\" width=\"100%\"> <tr> <td><strong>Passenger</strong></td> <td> </td> <td><strong>Weight</strong></td> <td> </td> <td><strong>Voucher</strong></td> <td> </td> <td><strong>Photos</strong></td> <td> </td> <td><strong>Mobile</strong></td> <td> </td> <td><strong>Work Phone</strong></td> <td> </td> <td><strong>Home Phone</strong></td> <td> </td> <td><strong>Notes</strong></td> </tr>"; $counter = 0; $bquery = mysql_query("select * from bookings where flight_id = '$id'"); while($bdata = mysql_fetch_array($bquery)) { $x=0; $phone = 0; $pquery = mysql_query("select * from passenger where booking_id = '$bdata[booking_id]'"); while($pdata = mysql_fetch_array($pquery)) { $x=1; $message .= "<tr> <td>$pdata[fname] $pdata[lname]</td> <td> </td> <td>$pdata[weight]</td> <td> </td> <td>$bdata[voucher]</td> <td> </td> <td>$bdata[photos]/$bdata[pax]</td> <td> </td> <td>$pdata[mobile]</td> <td> </td> <td>$pdata[wkph]</td> <td> </td> <td>$pdata[phone]</td> <td> </td> <td>$pdata[information]</td> </tr>"; $count = $count + $pdata[weight]; } } $message .= "</table> </td> </tr> <tr><td colspan=\"3\"><hr width=\"100%\"></td></tr> <tr> <td> <table align=\"center\"> <tr> <td> <table align=\"center\"> <tr> <td><strong>$data3[code]</strong></td> <td><strong>$data3[description]</strong></td> </tr> <tr><td>Total Pax</td><td>$data[pax]</td></tr> <tr><td>Total Pax Weight</td><td><strong>$count</strong></td></tr>"; $piquery = mysql_query("select * from pilots where pilot_id = '$data[pilot_id]'"); $pidata = mysql_fetch_array($piquery); $message .= "<tr><td>Pilot Weight</td><td>$pidata[weight]</td></tr> <tr><td>Empty Cylinder Weight</td><td>$data3[e_c_weight]</td></tr> <tr><td>Total Fuel at Departure</td><td>$data3[f_dept]</td></tr> <tr><td>Empty Balloon Weight</td><td>$data3[e_b_weight]</td></tr>"; $tlr = $count + $pidata[weight] + $data3[e_c_weight] + $data3[f_dept] + $data3[e_b_weight]; $message .= "<tr><td>Total Lift Required</td><td><strong>$tlr</strong></td></tr>"; $sdat = $dat[2]."/".$dat[1]; $sunq = mysql_query("select * from sun where date = '$sdat'"); $sund = mysql_fetch_array($sunq); if($data[am_pm] == 'AM' || $data[am_pm] == 'am'){$title = "Sunrise"; $sun = $sund[sunrise];} if($data[am_pm] == 'PM' || $data[am_pm] == 'pm'){$title = "Sunset"; $sun = $sund[sunset];} $message .="<tr><td>$title Time</td><td>$sun</td></tr> </table> </td> <td width=\"25\"> </td> <td valign=\"top\"> <table align=\"center\"> <tr><td colspan=\"2\"> </td></tr> <tr><td>Photos Sold by Pilot</td><td>__________</td></tr>"; if($data[am_pm] == 'AM' || $data[am_pm] == 'am'){$temp = $data3[am_temp]; $lift = $data3[am_lift];} if($data[am_pm] == 'PM' || $data[am_pm] == 'pm'){$temp = $data3[pm_tmep]; $lift = $data3[pm_lift];} $message .= "<tr><td>Datum Temperature</td><td>$temp</td></tr> <tr><td>Pressure Altitude</td><td>$data3[p_alt]</td></tr> <tr><td>Total Permitted Lift</td><td>$lift</td></tr> <tr><td>Total Lift Required</td><td>$tlr</td></tr>"; $und = $lift - $tlr; $message .="<tr><td>Underload</td><td><strong>$und</strong></td></tr> <tr><td>Next Check Due Hours</td><td>$data3[chk_hour]</td></tr>"; $ndat = explode("-", $data3[chk_date]); $message .="<tr><td>Next Check Due Date</td><td>$ndat[2]-$ndat[1]-$ndat[0]</td></tr> </table> </td> </tr> </table> </td> <td width=\"50\"> </td> <td valign=\"top\"> <table align=\"center\"> <tr><td colspan=\"2\"><strong>Landing Information</strong></td></tr> <tr><td>Name of Person Spoken to</td><td>_________________________</td></tr> <tr><td>Address</td><td>_________________________</td></tr> <tr><td>Telephone</td><td>_________________________</td></tr> <tr><td>Map Number</td><td>_________________________</td></tr> <tr><td>Grid Reference</td><td>_________________________</td></tr> <tr><td>Signature of Landowner/ Representative</td><td>_________________________</td></tr> </table> </td> </tr> </table> </td> </tr></table></body></html>"; #mail($to, "Pilot List", $message, $headers, $addit_param); $mail->AddAddress($to); //Replace with '$to' //$mail->AddAddress("[email protected]"); $mail->Subject = "Info List"; $mail->Body = $message; $sendout=$mail->Send(); $mail->ClearAddresses(); echo "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0;URL=/?page=list_flight\">"; ?> Any i'm trying to add this at the bottom of the email; but it gets a little messed up somewhere! <table width="200" border="1" align="center"> <tr> <td><table width="893" height="85" border="0"> <tr> <td height="40" colspan="3"><p><strong>OPERATIONS REPORT SHEET</strong><br /> </p></td> <td height="40">Photos available 2-3 days after flight.</td> </tr> <tr> <td>Date: <strong><? echo $dat[2]."-".$dat[1]."-".$dat[0]; ?></strong></td> <td>AM / PM <strong><? echo $data[am_pm]; ?></strong></td> <td>Balloon: <strong><? echo $data3[code]; ?></strong></td> <td width="158"> </td> </tr> <tr> <td>Pilot:</td> <td>Launch Site:<strong> <? echo $data2[location]; ?></strong></td> <td>Landing Map No/Grid Ref:</td> <td> </td> </tr> <tr> <td>Crew1: </td> <td> Vehicle 1: </td> <td>Mileage Out: </td> <td>Mileage In:</td> </tr> <tr> <td width="228">Crew 2: </td> <td width="235">Vehicle 2: </td> <td width="254">Mileage Out:</td> <td>Mileage In:</td> </tr> </table> <br /> <table width="891" height="521" border="0"> <tr> <td colspan="5"><p><strong><u>CHECKS OUT</u></strong><br /> </p></td> </tr> <tr> <td width="266">Sufficient Fuel For Trip </td> <td width="74">Yes</td> <td width="69">No</td> <td width="185"><strong>REMARKS TO OFFICE:</strong></td> <td width="275"> </td> </tr> <tr> <td>Does Pilot Need Maps </td> <td>Yes</td> <td>No</td> <td colspan="2">...</td> </tr> <tr> <td>Flight Bag </td> <td>Yes</td> <td>No</td> <td colspan="2"> </td> </tr> <tr> <td>Retrieve Maps </td> <td>Yes</td> <td>No</td> <td colspan="2">...</td> </tr> <tr> <td>Mobile Phone</td> <td>Yes</td> <td>No</td> <td colspan="2"> </td> </tr> <tr> <td>Tech Log & Pax List </td> <td>Yes</td> <td>No</td> <td colspan="2">...</td> </tr> <tr> <td>Flight Certificates </td> <td>Yes</td> <td>No</td> <td colspan="2"> </td> </tr> <tr> <td>Flight Certificates </td> <td>Yes</td> <td>No</td> <td colspan="2">...</td> </tr> <tr> <td>Fan & Petrol </td> <td>Yes</td> <td>No</td> <td colspan="2"><strong>BALLOON:</strong></td> </tr> <tr> <td>Restraint Line </td> <td>Yes</td> <td>No</td> <td colspan="2">...</td> </tr> <tr> <td>Gas In Balloon </td> <td>Yes</td> <td>No</td> <td colspan="2"> </td> </tr> <tr> <td>Number Plate on Trailer </td> <td>Yes</td> <td>No</td> <td colspan="2">...</td> </tr> <tr> <td>Met Balloons & Helium </td> <td>Yes</td> <td>No</td> <td colspan="2"> </td> </tr> <tr> <td>Camera & Memory Card</td> <td>Yes</td> <td>No</td> <td colspan="2">...</td> </tr> <tr> <td>Rain Covers</td> <td>Yes</td> <td>No</td> <td colspan="2"> </td> </tr> <tr> <td>Burner Poles </td> <td>Yes</td> <td>No</td> <td colspan="2">...</td> </tr> <tr> <td>Glasses</td> <td>Yes</td> <td>No</td> <td colspan="2"><strong>BALLOON:</strong></td> </tr> <tr> <td>Champagne (No of Bottles)</td> <td colspan="2"><div align="center">_________</div></td> <td colspan="2">...</td> </tr> <tr> <td>Orange Juice</td> <td>Yes</td> <td>No</td> <td colspan="2"> </td> </tr> <tr> <td>Whiskey </td> <td>Yes</td> <td>No</td> <td colspan="2">...</td> </tr> <tr> <td>Launch Site Keys </td> <td>Yes</td> <td>No</td> <td colspan="2"> </td> </tr> <tr> <td>Woodborough Gate Code <br /> </td> <td colspan="2"><div align="center">9221</div></td> <td colspan="2">...</td> </tr> <tr> <td>Oxford Bollard Code </td> <td colspan="2"><div align="center">020457</div></td> <td colspan="2"> </td> </tr> <tr> <td>Evesham Gate Code </td> <td colspan="2"><div align="center">3465 </div></td> <td colspan="2">...</td> </tr> <tr> <td colspan="3"> </td> <td colspan="2"><strong>VEHICLE/ TRAILER</strong></td> </tr> <tr> <td><strong>Signed:___________________________</strong></td> <td> </td> <td> </td> <td colspan="2">...</td> </tr> </table> <table width="891" height="405" border="0"> <tr> <td><p> </p></td> <td width="73"> </td> <td width="71"> </td> <td colspan="2"> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td colspan="2">...</td> </tr> <tr> <td colspan="2"><strong><u>CHECKS BACK</u></strong></td> <td> </td> <td colspan="2"> </td> </tr> <tr> <td width="268">Refuelled Balloon</td> <td>Yes</td> <td>No</td> <td colspan="2">...</td> </tr> <tr> <td><p>Cleaned: Vehicle</p></td> <td>Yes</td> <td>No</td> <td colspan="2"><strong>OTHER</strong></td> </tr> <tr> <td><p>Glasses</p></td> <td>Yes</td> <td>No</td> <td colspan="2">...</td> </tr> <tr> <td>Replaced: Radio etc</td> <td>Yes</td> <td>No</td> <td colspan="2"> </td> </tr> <tr> <td>Maps</td> <td>Yes</td> <td>No</td> <td colspan="2">...</td> </tr> <tr> <td>Tech Log</td> <td>Yes</td> <td>No</td> <td colspan="2"> </td> </tr> <tr> <td>Camera</td> <td>Yes</td> <td>No</td> <td colspan="2">...</td> </tr> <tr> <td>Champagne</td> <td>Yes</td> <td>No</td> <td colspan="2">SOLD ON SITE:</td> </tr> <tr> <td>Whiskey</td> <td>Yes</td> <td>No</td> <td width="153">Name of Cardholder:</td> <td width="304"> ....................................................................</td> </tr> <tr> <td>Keys</td> <td>Yes</td> <td>No</td> <td>Credit Card No.</td> <td>....................................................................</td> </tr> <tr> <td>Photo Taken</td> <td>Yes</td> <td>No</td> <td>Card Issue Date / No.</td> <td>....................................................................</td> </tr> <tr> <td>Refuelled Vehicle </td> <td>Yes</td> <td>No</td> <td>Card Expiry Date</td> <td>....................................................................</td> </tr> <tr> <td>Filling Station Location </td> <td colspan="2">_________________</td> <td>3 Digit Security No.</td> <td>....................................................................</td> </tr> <tr> <td height="21">Propane Tank</td> <td>lts</td> <td>%</td> <td>Address & Post Code:</td> <td>....................................................................</td> </tr> <tr> <td>Filling Station Location </td> <td colspan="2">_________________</td> <td colspan="2">...</td> </tr> <tr> <td colspan="3"><strong>Signed:</strong></td> <td>Tel: ...............................</td> <td>Amount £</td> </tr> </table> <br /> <table width="906" border="1"> <tr> <td width="169"><strong>OFFICE USE </strong></td> <td width="288">CHECKED</td> <td width="252">DATE</td> <td width="169">BY</td> </tr> </table></td> </tr> </table> Thanks Neil[/code][/code][/code] Link to comment https://forums.phpfreaks.com/topic/101835-php-email-not-working-correctly-any-ideas/ Share on other sites More sharing options...
chigley Posted April 19, 2008 Share Posted April 19, 2008 Did you remember to escape the quotes? Link to comment https://forums.phpfreaks.com/topic/101835-php-email-not-working-correctly-any-ideas/#findComment-521130 Share on other sites More sharing options...
neilw_uk Posted April 19, 2008 Author Share Posted April 19, 2008 By escape do you mean: <table width=\"200\" border=\"1\" align=\"center\"> ? I did do this to all the html... but forgot to paste that copy in here. Link to comment https://forums.phpfreaks.com/topic/101835-php-email-not-working-correctly-any-ideas/#findComment-521132 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.