我正在尝试编写 cron 作业,因此如果数据库中的代码未使用且超过 72 小时,它将删除数据库中的行。
但是,我遇到的问题是,当我尝试连续获取数组数据时,我可以运行“If 语句”然后运行 drop 命令,在打印数组时,我会得到如下所示的重复项
33520891520891do not usedo not use----aaron hattonaaron hattonSunday 8th of September 2013 12:46:20 PMSunday 8th of September 2013 12:46:20 PMUnusedUnused--
我的代码如下
// Set variable for the time
$timenow = date('l jS \of F Y h:i:s A');
// Start Expired password check and drop function
function cronexec_expired ($timenow) {
include('../../config.php');
// Open up a new MySQLi connection to the MySQL database
mysql_connect($dbHost, $dbUsername, $dbPassword);
mysql_select_db($dbTable);
// Query to check the status of the code input
$expiry_check = "SELECT * FROM code_log WHERE status='Unused'";
// Run the query
$expiry_checkexec = mysql_query($expiry_check);
while($expiry_possibles = mysql_fetch_array($expiry_checkexec)) {
foreach ($expiry_possibles as $expiry_possible) {
print_r ($expiry_possible);
};
}
}
// Start Redeemed Password check and drop function
// Execute Functions
cronexec_expired ($timenow);
任何帮助将非常感激!
编辑
删除“foreach”并运行以下命令时:
print_r ($expiry_possibles);
我得到以下
Array ( [0] => 3 [id] => 3 [1] => 520891 [code] => 520891 [2] => do not use [refid] => do not use [3] => - [hostname] => - [4] => - [userip] => - [5] => aaron hatton [creater] => aaron hatton [6] => Sunday 8th of September 2013 12:46:20 PM [timecreated] => Sunday 8th of September 2013 12:46:20 PM [7] => Unused [status] => Unused [8] => - [timeredeemed] => - )
难道我做错了什么?