drjk87189 2015-03-07 03:56
浏览 5

苦苦于简单的数据库更新

This is a cronjob to check where a users subscription has expired. There are 4 different types of subscription.

However I'm completely lost as to why it doesn't update the database when I run the command.

Below is the script:

$sub = mysql_query("SELECT turboexpires,platinumexpires,goldexpires,silverexpires FROM $tab[user] WHERE id='$id'");
    $expire = mysql_fetch_array($sub);
    echo "".$expire['0'].""; 
    echo "".$time."";

    if($expire[0] <= $time){ mysql_query("UPDATE $tab[user] SET turbo='no' AND turboexpires='0' WHERE id='$id'"); }
    if($expire[1] <= '$time'){ mysql_query("UPDATE $tab[user] SET platinum='no', platinumexpires='0' WHERE id='$id'"); }
    if($expire[2] <= '$time'){ mysql_query("UPDATE $tab[user] SET gold='no', goldexpires='0' WHERE id='$id'"); }
    if($expire[3] <= '$time'){ mysql_query("UPDATE $tab[user] SET silver='no', silverexpires='0' WHERE id='$id'"); }

I put the echo's in to check that they were working and they are.

$expire[0] comes back with a unix timestamp, in this case a past one. $time comes back with the current unix timestamp.

I also tried removing the '' around $time as shown above with no luck.

However, when I then proceed with the command nothing happens in the database.

Hopefully an easy problem, I've just been looking at it for so long I'm completely lost!

Thanks for any help!

P.S yes I know I need to upgrade to mysqli, it's on the todo list haha!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 关于大棚监测的pcb板设计
    • ¥15 stm32开发clion时遇到的编译问题
    • ¥15 lna设计 源简并电感型共源放大器
    • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
    • ¥15 Vue3地图和异步函数使用