huckfinne Posted May 8, 2009 Share Posted May 8, 2009 <?php $from = '[email protected]'; $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. 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. 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 />'; 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? 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. 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. Link to comment https://forums.phpfreaks.com/topic/157399-solved-help-please/#findComment-829766 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.