elmas156 Posted October 28, 2010 Share Posted October 28, 2010 I'm trying to send an email that has a list created from a while loop to multiple people with an email list created from while loop. Can someone please help me figure this out? My brain is fried. Here's the code that I have: This is producing an error message that reads: Parse error: syntax error, unexpected '{' in /home/content/29/6879529/html/calhoun/admin/sendreport.php on line 22 <?php include("conf.inc.php"); $result = mysql_query("SELECT `prefix`,`lname`,`email` FROM admin"); $row = mysql_fetch_row($result); $result2 = mysql_query("SELECT `to`,`from`,`subject`,`message`,`date` FROM allmsgs WHERE reported = 'n' ORDER BY `messid` ASC"); $row2 = mysql_fetch_row($result2); $cdate = date('m-d-Y'); while ($row = mysql_fetch_row($result)) { $prefix = $row[0]; $lname = $row[1]; $adminemail = $row[2]; $fullname = "$prefix $lname"; $sendto = "$adminemail"; $emailsubject = "Webstats Report For $cdate."; while ($row2 = mysql_fetch_row($result2){ // This is line 22. $to = $row2[0]; $from = $row[1]; $subject = $row[2]; $message = $row[3]; $datetime = $row[4]; $eachmessage = "<p> <hr width=\"400\"> To: $to<br> From: $from<br> On $datetime<br> <br> $subject<br>$nbsp;<br> $message </p>"; } $emailmessage = "<html> <body> $fullname, <p> Here is a list of the messages that have been exchanged in the last 24 hours.</p> $eachmessage </body> </html>"; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= 'From: Webstats <reports@webstats.com>' . "\r\n"; // Mail it mail($sendto, $emailsubject, $emailmessage, $headers); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/217126-mailing-with-while-loops/ Share on other sites More sharing options...
taquitosensei Posted October 28, 2010 Share Posted October 28, 2010 you forgot a parenthesis while ($row2 = mysql_fetch_row($result2){ should be while ($row2 = mysql_fetch_row($result2)) { Quote Link to comment https://forums.phpfreaks.com/topic/217126-mailing-with-while-loops/#findComment-1127661 Share on other sites More sharing options...
Pikachu2000 Posted October 28, 2010 Share Posted October 28, 2010 You're missing a closing parenthesis before the opening curly brace on that line. Quote Link to comment https://forums.phpfreaks.com/topic/217126-mailing-with-while-loops/#findComment-1127663 Share on other sites More sharing options...
elmas156 Posted October 28, 2010 Author Share Posted October 28, 2010 OK, thanks for pointing that out. Now I'm not getting the error message, but I'm not getting any emails sent either. Is there a problem with the while loops that would cause a problem sending the emails? I've never tried this before so I'm thinking there might be something wrong with the structure but I'm not sure. Any suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/217126-mailing-with-while-loops/#findComment-1127673 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.