我遵循这个主题,因为我有同样的问题(不能使用命令shell,只需编辑文件主机) - > change a value after 24 hours
首先运行SQL
CREATE TABLE `php_cron` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`last_ts` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
);
INSERT INTO `php_cron` (`id`, `last_ts`) VALUES (1,'2012-08-10 00:00:00');
我的代码
$res1 = mysql_query("SELECT TIME_TO_SEC(TIMEDIFF(NOW(), last_ts)) AS tdif FROM php_cron WHERE id=1");
$dif = mysql_fetch_assoc($dif['tdif']);
if ($dif >= 86400) { //24h
//following code will run once every 24h
//update user's page rank
$sql2 = "UPDATE logs_limitbandwidthtoday SET BandwidthToday = 0";
mysql_query($sql2);
$sql23 = "UPDATE logs_limitlinktoday SET LimitLink = 0";
mysql_query($sql23);
$sql24 = "UPDATE logs_limitvipbw SET BandwidthToday = 0";
mysql_query($sql24);
$sql25 = "UPDATE logs_limitviplink SET LimitLink = 0";
mysql_query($sql25);
$sql26 = "UPDATE account_vip SET ALLTime = ALLTime - 1 WHERE ALLTime > 0";
mysql_query($sql26);
//update last execution time
$sql3 = "UPDATE php_cron SET last_ts = NOW() WHERE id=1";
mysql_query($sql3);
}
错误 - > PHP警告:mysql_fetch_assoc()期望参数1为资源,在第2行的/ ....中给出null
我不确定此代码是否仍然有效,请给我一个这个问题的答案。非常感谢你!
答案 0 :(得分:0)
好的,这应该可以解决问题
$('.toShow .dslc-modules-area:not(:first)').addClass("hide");
$( ".links li" ).click(function() {
$( ".links li" ).siblings().removeClass('active');
$(this).toggleClass('active');
var identify=$(this).index();
$(".toShow .dslc-modules-area:not(:eq(identify))").addClass("hide");
$(".toShow .dslc-modules-area").eq([identify]).removeClass('hide').toggleClass("showme");
$('html,body').animate({scrollTop: $(".toShow").offset().top + 0}, 800);
但是由于mysql_ *已经过时并从PHP 7.0中删除,更新的代码应该是这样的
$dif = mysql_fetch_assoc($res1);
$dif1 = $dif['tdif'];
if ($dif1 >= 86400) {
其中$ con是您使用数据库进行的连接
$res1 = mysqli_query($con,"SELECT TIME_TO_SEC(TIMEDIFF(NOW(), last_ts)) AS tdif FROM php_cron WHERE id=1");
$dif = mysqli_fetch_assoc($res1);
$dif1 = $dif['tdif'];
if ($dif1 >= 86400) {
//following code will run once every 24h
//update user's page rank
$sql2 = "UPDATE logs_limitbandwidthtoday SET BandwidthToday = 0";
mysqli_query($con,$sql2);
$sql23 = "UPDATE logs_limitlinktoday SET LimitLink = 0";
mysqli_query($sql23);
$sql24 = "UPDATE logs_limitvipbw SET BandwidthToday = 0";
mysqli_query($con,$sql24);
$sql25 = "UPDATE logs_limitviplink SET LimitLink = 0";
mysqli_query($con,$sql25);
$sql26 = "UPDATE account_vip SET ALLTime = ALLTime - 1 WHERE ALLTime > 0";
mysqli_query($con,$sql26);
//update last execution time
$sql3 = "UPDATE php_cron SET last_ts = NOW() WHERE id=1";
mysqli_query($con,$sql3);
}