Jump to content

Recommended Posts

Hello,

 

I'm having trouble getting a URL to display in emails without breaking the loop.

 

When an admin processes the answers to questions at the end of the week, I want an email to be sent to each user to notify them that the answers have been processed.

 

This works fine if the email body doesn't have a URL in the body, but if it does have the URL, only the first person in the database recieves the email. It is perfectly formatted with an active URL. No problem with that email. But subsequent emails are not sent.

 

Here is the code:

 

//Send Email

$subject = "Subject";
$headers = "FROM: admin@address.com\n";

$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: multipart/alternative;\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "Content-Transfer-Encoding: 7bit";
$headers .= "\r\n";


$sql = mysql_query("SELECT * FROM games WHERE round='$round'") or die(mysql_error());
$i = 0;
while ($rw = mysql_fetch_assoc($sql)) {
    if ($i == 20) {
        sleep(1);
        $i = 0;
    }


$message ="Hello " . $rw['username'] . ",\n\n" . "Your answers have been processed, please visit http://www.example.com/ to see how you fared against everyone else! \n\n" . "Admin";

   $to = $rw['email'];
     mail($to, $subject, $message, $headers);
     $i++;
}
mysql_free_result($sql);

 

As I said, without the URL it is fine, but I'd rather have a link that people can click on to quickly see their scores.

Link to comment
https://forums.phpfreaks.com/topic/88120-url-breaking-while-loop/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.