-1
我想使用PHPmailer在一个while循环中向多个人发送电子邮件。但是,只要循环到达include '../email/PHPMailerAutoload.php';
行,就会在while循环内停止。完整的代码看起来像这样PHPMailer破坏While循环
<?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);
}
?>
任何想法?
将'include'移到循环之前。总是在开发和测试PHP代码时,启用错误显示。在脚本的顶部,'error_reporting(E_ALL); ini_set('display_errors',1);'最有可能你会发现PHP抱怨你试图重新声明一个类或类似的东西。在循环中包含/需要文件几乎是不必要的或不可取的。 –
你正在包括自动加载EVERT TIME ROUND THE LOOP标题应该是_“我怎么摧毁了这个while循环”_ – RiggsFolly
谢谢大家,特别是Michael Berkowski :) – user5095266