douye2020 2016-07-30 19:31
浏览 19
已采纳

PHPMailer破坏了While循环

I want to send e-mails to multiple persons in a while loop using PHPmailer. But as soon as the loop gets to the row include '../email/PHPMailerAutoload.php'; it stops inside the while loop. The full code looks like this

<?php
    $result = $con->prepare('SELECT * from table WHERE Date = ?');
    $result->execute([$Date]);
    while($row = $result->fetch(PDO::FETCH_BOTH)){
        $Email=$row['Email'];   
        include '../email/PHPMailerAutoload.php';
        email_function($Email);
    }
?>

Any ideas?

  • 写回答

1条回答 默认 最新

  • doudang2817 2016-07-30 19:34
    关注

    The PHPMailerAutoload.php must be included/called once! Please try this:

    include '../email/PHPMailerAutoload.php';
    $result = $con->prepare('SELECT * from table WHERE Date = ?');
    $result->execute([$Date]);
    while($row = $result->fetch(PDO::FETCH_BOTH)){
        $Email=$row['Email'];   
        email_function($Email);
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?