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();?> Quote Link to comment 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();?> Quote Link to comment 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();?> Quote Link to comment 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); Quote Link to comment Share on other sites More sharing options...
shenmue232 Posted September 5, 2007 Author Share Posted September 5, 2007 Thanks for all the help guys Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted September 5, 2007 Share Posted September 5, 2007 GUYS??? I did that all by myself!!!!!!!! Quote Link to comment 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.