huckfinne Posted May 8, 2009 Share Posted May 8, 2009 <?php $from = 'huckfinne@mac.com'; $subject = $_POST['subject']; $text = $_POST['elvismail']; $dbc = mysql_connect('localhost:8888', 'playPHP', '') or die('Error connecting to MySQL server.'); mysql_select_db("elvis_store", $dbc); $query = "SELECT * FROM email_list"; $result = mysql_query($query) or die('Error querying database.'); while($row = mysql_fetch_array($result)) { $first_name = $row['first_name']; $last_name = $row['last_name']; $message = "Dear $first_name $last_name,\n $text."; $to = $row['email']; mail($to, $subject, $message, 'From:' $from); echo 'Email sent to:' $to '<br />'; } mysql_close($dbc); ?> When I run the above program I get "Parse error: syntax error, unexpected T_VARIABLE in /Applications/MAMP/htdocs/sendmail.php on line 23." I've isolated it to the last two lines in the loop, but cannot for the life of me figure out what the issue is. Any thoughts would be very much appreciated. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/157399-solved-help-please/ Share on other sites More sharing options...
premiso Posted May 8, 2009 Share Posted May 8, 2009 echo 'Email sent to:' . $to . '<br />'; You were missing the concatenation operator (if that is the correct term) Note the periods. Quote Link to comment https://forums.phpfreaks.com/topic/157399-solved-help-please/#findComment-829749 Share on other sites More sharing options...
Ken2k7 Posted May 8, 2009 Share Posted May 8, 2009 You can do this too. echo 'Email sent to:', $to, '<br />'; Quote Link to comment https://forums.phpfreaks.com/topic/157399-solved-help-please/#findComment-829750 Share on other sites More sharing options...
huckfinne Posted May 8, 2009 Author Share Posted May 8, 2009 Thanks for the quick response, but no joy on either of those options. I tried them both with no change in the error message. Any more thoughts? Quote Link to comment https://forums.phpfreaks.com/topic/157399-solved-help-please/#findComment-829761 Share on other sites More sharing options...
premiso Posted May 8, 2009 Share Posted May 8, 2009 Missed this one as well: mail($to, $subject, $message, 'From:' . $from); Same error, you missed the concatenation period. Quote Link to comment https://forums.phpfreaks.com/topic/157399-solved-help-please/#findComment-829762 Share on other sites More sharing options...
huckfinne Posted May 8, 2009 Author Share Posted May 8, 2009 Beautiful. Thanks for the help. Quote Link to comment https://forums.phpfreaks.com/topic/157399-solved-help-please/#findComment-829766 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.