Hi,
I have been working on this for two days now and it is really bugging me as to why it is not working!
I have a while statement that gets users out of the database and sends emails to all of them.
I use the $buffer method to ob_start and $buffer = ob_get_contents in the included file.
So far everything is working fine. I then wanted to create a personal touch to the newsletter by sending the client name and details to the included page that is buffered using session variables.. Wow it worked... No it didn't.
well it is picking up the session vars ok, but not looping through them. I get the same value for name for all users instead of looping through the database.
The bit that really gets me is that if I print the session vars to the screen it shows them corretly looping through the while statement. The emails are also being sent correctly to all users in the database ie $email is sending to all the users in the while loop
The issue seems to occure once the buffer has been run it doesn't go throught the while statement. I have tried all different methods to get the buffer to pick up the correct variables. I have a feeling that it is because I am not clearing the cache correctly in the loop and reloading it. or that becauase i am including the file once the buffer only runs once?
If anyone can help me before I slit my wrists I would really appreciate it.
while ($results = mysql_fetch_array($qid2)) {
$email = $results["email"];
$name = $results["name"];
$country = $results["country"];
$state = $results["state"];
$email_recipient_id = $results["email_recipient_id"];
$c_name_stripped = $results["c_name_stripped"];
$_SESSION['email'] = $results["email"];
$_SESSION['name'] = $results["name"];
$_SESSION['email_recipient_id'] = $results["email_recipient_id"];
$_SESSION['c_name_stripped'] = $results["c_name_stripped"];
// Personal Information using session variables
// end load personl information variables
$session_num ++;
echo $session_num;
echo $_SESSION['name'];
include_once("email_system/buffer_newsletter_send.php");
$newsletter_id = $_SESSION['new_newsletter_id'];
$qid_newsletter = db_query("SELECT * from newsletters WHERE newsletter_id = '$newsletter_id' Group By newsletter_id");
$newsletter_results = mysql_fetch_array($qid_newsletter);
$subject = $newsletter_results["subject"];
$message = $newsletter_results["message"];
$closing_statement = $newsletter_results["closing_statement"];
$message = $buffer; //'.$buffer.'
// mail function
mail($email,$subject,
'
'.$message.'
',
"To: $name <$email>\n" .
"From: $c_name_stripped <$from_email>\n" .
"MIME-Version: 1.0\n" .
"Content-type: text/html; charset=iso-8859-1");
// End Mail Function
} // end of while loop
in the included files I have
// Start buffering
ob_start ();
// My content mixed html and php suff with echo printing variables
$buffer = ob_get_clean();
Please Help! or guide me to an alternative method.