jeff5656 Posted June 17, 2009 Share Posted June 17, 2009 This code successfully sends out an email with the $message containing everything in the WHILE loop but I get this error: Notice: Undefined variable: txt in E:\wamp\www\gpu\amnotify.php on line 27 here's the code: $query2 = "SELECT * FROM `gpu` WHERE `signoff_status` = 'a' and `service` = 'f2a' "; $result2 = mysql_query ($query2) or die ("Invalid query: " . mysql_error ()); while ($row2 = mysql_fetch_assoc ($result2)) { $newdate3 = date("m/d/Y", strtotime($row2['rcf_date2'])); $txt .= $row2['patient'] . " (" . $row2['mrn'] . ") " . $newdate3 ." Dx: " . $row2['dx']. "\n<br>"; } $message = "Good morning Dr. " . $whoto . ",<br>" . "This is the census for F2a:<br>" . $txt; $subject = "Notification of GPU admission"; $headers = "From: [email protected]"; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $sent = mail($to, $subject, $message, $headers); Link to comment https://forums.phpfreaks.com/topic/162657-solved-undefined-variable/ Share on other sites More sharing options...
smerny Posted June 17, 2009 Share Posted June 17, 2009 try txt=""; before the loop? Link to comment https://forums.phpfreaks.com/topic/162657-solved-undefined-variable/#findComment-858455 Share on other sites More sharing options...
jeff5656 Posted June 17, 2009 Author Share Posted June 17, 2009 I put this before the while loop and it worked. $txt = ''; thanks. Link to comment https://forums.phpfreaks.com/topic/162657-solved-undefined-variable/#findComment-858456 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.