Author Topic: DATABASE MAIL  (Read 573 times)

0 Members and 1 Guest are viewing this topic.

Offline shenmue232Topic starter

  • Irregular
  • Posts: 9
    • View Profile
DATABASE MAIL
« on: August 30, 2007, 01:20:59 PM »
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>&nbsp;</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();?>

Offline ToonMariner

  • Fanatic
  • Posts: 3,715
  • Gender: Male
    • View Profile
Re: DATABASE MAIL
« Reply #1 on: August 30, 2007, 01:41:23 PM »
Code: [Select]
<?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>&nbsp;</p>" $_POST['comment'], $header 'From: ' $row['email'] . PHP_EOL);
  }

header "Location: thanks.html" );

mysql_close($con);//close connection

?>


</html>

<?php ob_end_flush();?>
follow me on twitter @PHPsycho

Offline shenmue232Topic starter

  • Irregular
  • Posts: 9
    • View Profile
Re: DATABASE MAIL
« Reply #2 on: August 31, 2007, 01:19:45 PM »
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>&nbsp;</p>" . $_POST['comment'], $header . 'From: ' $row['email'] . PHP_EOL);
  }

header ( "Location: thanks.html" );

mysql_close($con);//close connection

?>

</html>

<?php ob_end_flush();?>
« Last Edit: August 31, 2007, 01:20:47 PM by shenmue232 »

Offline ToonMariner

  • Fanatic
  • Posts: 3,715
  • Gender: Male
    • View Profile
Re: DATABASE MAIL
« Reply #3 on: September 02, 2007, 09:01:40 PM »
 mail($row['email'],"Email From Customer","Message:<p>&nbsp;</p>" . $_POST['comment'], $header . 'From: ' $row['email'] . PHP_EOL);

missed out a concatenation!!!!

try this

 mail($row['email'],"Email From Customer","Message:<p>&nbsp;</p>" . $_POST['comment'], $header . 'From: ' . $row['email'] . PHP_EOL);
follow me on twitter @PHPsycho

Offline shenmue232Topic starter

  • Irregular
  • Posts: 9
    • View Profile
Re: DATABASE MAIL
« Reply #4 on: September 05, 2007, 04:08:27 AM »
Thanks for all the help guys

Offline ToonMariner

  • Fanatic
  • Posts: 3,715
  • Gender: Male
    • View Profile
Re: DATABASE MAIL
« Reply #5 on: September 05, 2007, 04:58:24 AM »
GUYS???

I did that all by myself!!!!!!!!
follow me on twitter @PHPsycho