gpt4 book ai didi

php - 一定时间后删除非事件用户有问题吗?

转载 作者:太空宇宙 更新时间:2023-11-03 12:14:37 25 4
gpt4 key购买 nike

我有这段代码可以在经过一定时间后删除未激活的用户,在本例中为 7 天。虽然脚本似乎根本不起作用?什么都没发生?当我删除重定向链接时,它只显示一个空白页面。尝试回显信息,但没有任何显示?

<?php
$dbhost = 'mysql.hostinger.co.uk';
$dbuser = 'u634727706_admin';
$dbpass = '';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
$checkdate= "SELECT username, signup_date FROM users WHERE activated='0'";

$checkdate2 = mysql_query($checkdate);

while($checkdate3 = mysql_fetch_array($checkdate2)){
$user = $checkdate3['username'].' ';
$date = $checkdate3['signup_date'].' ';


$start = strtotime("$date");
// get today's date
$today = strtotime("now");

// find difference (in seconds)
$time_elapsed = $today - $start;

// get days elapsed
$days_elapsed = $time_elapsed/86400;


if($days_elapsed >= 7){
mysql_query ("DELETE FROM users WHERE username='$user'") or die ("update didn't work");
echo '<meta http-equiv="refresh" content="0;url=http://basecentre.co.uk/admin.php?page=5&cron=3">';
exit();
}
}
echo '<meta http-equiv="refresh" content="0;url=http://basecentre.co.uk/admin.php?page=5">';
?>

最佳答案

尝试在数据库中完成所有操作:

DELETE FROM users
WHERE activated = '0' AND signup_date < now() - interval 7 day;

关于php - 一定时间后删除非事件用户有问题吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22745493/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com