简体   繁体   中英

What is wrong with this INTERVAL syntax in my PHP MYSQL code?

I can't seem to get the database to update when INTERVAL is set

$update_query="UPDATE subscriber SET txn_type='$txn_type', expire_date=(CURDATE(),INTERVAL 1 MONTH), subscription_type='$item_name', last_payment = NOW(), subscr_id ='$subscr_id', txnid = '$txn_id', payment_status='paid' WHERE id= '$id'"; 

But w/o INTERVAL it works fine

$update_query="UPDATE subscriber SET txn_type='$txn_type', expire_date=CURDATE(), subscription_type='$item_name', last_payment = NOW(), subscr_id ='$subscr_id', txnid = '$txn_id', payment_status='paid' WHERE id= '$id'"; 

Everywhere I look, this seems to be the correct way to set interval. Am I missing something?

我猜你是说要增加1个月:

expire_date= CURDATE() + INTERVAL 1 MONTH,

尝试这个

  expire_date=DATE_ADD(NOW(), INTERVAL 1 MONTH)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM