我正在编写一个程序,通过Godaddy使用 MySQL,PHP和Cron作业发送延迟电子邮件。最终,这将是一个自动化过程,但暂时我手动完成所有操作。发送电子邮件后,我希望从名为mailbox的数据库表中删除它们。当我尝试编写擦除表格的代码时,我遇到了一个问题。我目前正在尝试使用"TRUNCATE TABLE mailbox"
,但也尝试"DELETE FROM mailbox"
没有运气。我还删除了后面的刻度并收到了不良结果。目前该文件如下所示:
<?php
require_once( ".htpasswd2" );
$mailQuery = "select * from mailbox";
$mailResults = mysql_query( $mailQuery );
for( $i = 0; $i < mysql_num_rows( $mailResults ); $i++ ) {
$mailArray = mysql_fetch_array( $mailResults );
$msg = "On " . date('M jS, Y') . " at " . date('g:i:sa') .
" " . $mailArray[ 'from' ] . " wrote <p>" . $mailArray[ 'message' ];
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-Type: text/html; charset=iso-8859-1" . "\r\n";
$headers .= "To: " . $mailArray[ 'to' ] . "\r\n";
$headers .= "From: " . $mailArray[ 'from' ] . "<" . $mailArray[ 'reply' ] . ">" . "\r\n";
mail( $mailArray['to'], $mailArray['subject'], $msg, $headers );
}
$clearTable = "TRUNCATE TABLE mailbox";
mysql_query( $clearTable );
?>
任何帮助将不胜感激!谢谢!
答案 0 :(得分:0)
这可能有用
$clearTable = " TRUNCATE TABLE `mailbox` ";