PHP Newsletter problems

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
m_roos81
Forum Newbie
Posts: 2
Joined: Thu Apr 22, 2004 6:53 am

PHP Newsletter problems

Post by m_roos81 »

Hello everybody,

I'm working on a PHP newsletter system for my website.
As people subscribe for the newsletter, they need to choose their fields of interest from a list of 5. They need to pick at least 1 interest, but can also pick all 5.

If a newsletter is sent, there is a text that everybody gets, no matter what interest they signed up for. After that, there is a text for every different interest.

A small example: if somebody is signed up for interest 1 and 5, they need to get the general text, the text for interest 1 and the text for interest 5.

I hope I made clear what I want to do.

Here is the code I have so far:

Code: Select all

$query="SELECT personen.persoon_id, personen.email, interesse_persoon.interesse_id FROM personen JOIN interesse_persoon 
ON personen.persoon_id = interesse_persoon.persoon_id ORDER BY persoon_id";

$res=mysql_query($query);
while($sendemail=mysql_fetch_array($res)){ //I think there is something wrong in this line
$lastid="";
$to = $sendemailї"email"];
$from = "Michael Roos<m.roos@proeducation.nl>";
 
$subject = $mail->onderwerp->GetText();
$message&#1111;0]= $mail->tekst->GetText(); //This text is ment for everybody on the list
$message&#1111;1]= $mail->tekst1->GetText(); //This text is only ment for people with interest1
$message&#1111;2]= $mail->tekst2->GetText(); //This text is only ment for people with interest2
$message&#1111;3]= $mail->tekst2->GetText(); //This text is only ment for people with interest3
$message&#1111;4]= $mail->tekst2->GetText(); //This text is only ment for people with interest4
$message&#1111;5]= $mail->tekst2->GetText(); //This text is only ment for people with interest5
 
$headers = "From: $from\nReply-To: $from\nContent-Type: text/html";
while(mysql_num_rows($res) && $row=mysql_fetch_array($res))&#123;
if($lastid <> $row&#1111;"persoon_id"] && $lastid <> "") mail ($to, $subject, "$message&#1111;0]<p>$suffix", $headers);
$suffix.="<P>".$message&#1111;$row&#1111;"interesse_id"]];
$lastid=$row&#1111;"persoon_id"];
&#125;
&#125;
I think there is something wrong with the way the e-mailaddresses are fetched from the database. I have 3 addresses in my test-database, but only 1 e-mail is sent.

I'm not at all a PHP-expert so the fault can be somewhere else as well.

Can somebody help me out here? That would be great!

Many thanks,

Michael Roos
Holland
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

put an echo "email sent to $sendemail[email]"; in that while loop and see if it goes through the loop more than once
m_roos81
Forum Newbie
Posts: 2
Joined: Thu Apr 22, 2004 6:53 am

Post by m_roos81 »

Hello,

Thanks for quick reply.
I've put that echo in the first-while loop, but it only goes trough one time.

There actually two e-mails sent. I signed myself up to test for interest 1 and 2... So I'm supposed to get one e-mail with the text from $message[0], $message[1] and $message[2].

Instead of that, I get one e-mail with $message[0] and $message[1], while the second e-mail included $message[0], $message[1] and $message[2].

Like I said: I just want all my subscribers to receive just one e-mail with only the texts for the interests they have signed up for.

OK, the first thing that goes wrong is while fetching the e-mailaddresses from the database in the first while-loop.

Is there anybody who can help me make it work?

Thanks!

Michael
Post Reply