shenmue232 Posted August 30, 2007 Share Posted August 30, 2007 Hi everyone I have a table called tbl_emails with a column called email this table has a list of emails, what i want to do is email everyone in the table here is my code so far: <?php ob_start();?> <html> <?php $con = mysql_connect(""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("shenmue232", $con);// database name $result = mysql_query("SELECT * FROM tbl_emails"); while($row = mysql_fetch_array($result)) { echo $row['email']; echo "<br />"; } $comment =$_POST['comment']; $email =['email']; mail ( "$email" ,"Email From Customer", "Message:<p> </p> $comment", "From: $email \nContent-Type: text/html; charset=iso-8859-1"); header ( "Location: thanks.html" ); mysql_close($con);//close connection ?> </html> <? ob_end_flush();?> Link to comment https://forums.phpfreaks.com/topic/67325-database-mail/ Share on other sites More sharing options...
ToonMariner Posted August 30, 2007 Share Posted August 30, 2007 <?php ob_start();?> <html> <?php $con = mysql_connect(""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("shenmue232", $con);// database name $result = mysql_query("SELECT * FROM tbl_emails"); $header = 'Content-Type: text/html; charset=iso-8859-1' . PHP_EOL; while($row = mysql_fetch_array($result)) { mail($row['email'],"Email From Customer","Message:<p> </p>" . $_POST['comment'], $header . 'From: ' $row['email'] . PHP_EOL); } header ( "Location: thanks.html" ); mysql_close($con);//close connection ?> </html> <?php ob_end_flush();?> Link to comment https://forums.phpfreaks.com/topic/67325-database-mail/#findComment-337775 Share on other sites More sharing options...
shenmue232 Posted August 31, 2007 Author Share Posted August 31, 2007 Hi i have made the changes to the code but i get this error message: Parse error: syntax error, unexpected T_VARIABLE in /home/content/n/e/w/newman100/html/holmwoodlandscapes/sendmail.php on line 21 Here is the code so far: <?php ob_start();?> <html> <?php $con = mysql_connect("");//connect to server if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("shenmue232", $con);// database name $result = mysql_query("SELECT * FROM tbl_emails WHERE email > 0"); echo mysql_num_rows($result); $header = 'Content-Type: text/html; charset=iso-8859-1' . PHP_EOL; while($row = mysql_fetch_array($result)) { mail($row['email'],"Email From Customer","Message:<p> </p>" . $_POST['comment'], $header . 'From: ' $row['email'] . PHP_EOL); } header ( "Location: thanks.html" ); mysql_close($con);//close connection ?> </html> <?php ob_end_flush();?> Link to comment https://forums.phpfreaks.com/topic/67325-database-mail/#findComment-338706 Share on other sites More sharing options...
ToonMariner Posted September 3, 2007 Share Posted September 3, 2007 mail($row['email'],"Email From Customer","Message:<p> </p>" . $_POST['comment'], $header . 'From: ' $row['email'] . PHP_EOL); missed out a concatenation!!!! try this mail($row['email'],"Email From Customer","Message:<p> </p>" . $_POST['comment'], $header . 'From: ' . $row['email'] . PHP_EOL); Link to comment https://forums.phpfreaks.com/topic/67325-database-mail/#findComment-340160 Share on other sites More sharing options...
shenmue232 Posted September 5, 2007 Author Share Posted September 5, 2007 Thanks for all the help guys Link to comment https://forums.phpfreaks.com/topic/67325-database-mail/#findComment-341909 Share on other sites More sharing options...
ToonMariner Posted September 5, 2007 Share Posted September 5, 2007 GUYS??? I did that all by myself!!!!!!!! Link to comment https://forums.phpfreaks.com/topic/67325-database-mail/#findComment-341927 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.