frankie
frankie

Reputation: 673

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?

Upvotes: 0

Views: 40

Answers (2)

thumber nirmal
thumber nirmal

Reputation: 1617

try this

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

Upvotes: 1

Joni
Joni

Reputation: 111259

I'm guessing you mean to add 1 month:

expire_date= CURDATE() + INTERVAL 1 MONTH,

Upvotes: 5

Related Questions