This topic is locked
[SOLVED]

 Custom Button not working right

1/22/2020 7:18:31 AM
PHPRunner General questions
H
harveyspecter author

I have an edit page.
I made a button on edit page. It needs to delay the due date (son_tarih is due date) of work 1 month later.
It has an error. For example if "son_tarih" is 01.01.2020 its loading page for a while and nothing happens. So when i check it again by refreshing. Due date (son_tarih) is 01.05.3863. Code runs like 50000 times. And bcuz of it it doesnt return back to list page also.
Server:



while($record = $button->getCurrentRecord())

{

$ID = $record["ID"];

$sontarih = $record["son_tarih"];

$ertelemetarihi = date('Y-m-d', strtotime($sontarih. ' + 1 month'));

$sql = "UPDATE is_takip_new SET son_tarih='$ertelemetarihi' where ID=".$ID;

DB::Exec($sql);

}


Client After:



location.href="is_takip_new_list.php?a=return";


Can you help me? I need it to run once and make 01.01.2020 to 01.02.2020 and return to list page.

A
acpan 1/22/2020

Log all your values and print out will normally help you solve the problem yourself. and if still having problem, post your log values here.
The SQL is running many times probably your id is wrong or empty, which affects all the records.
So log the sql statement and run manually in SQL editor will show you the error.
Again log date variables and show it and you can tell if the date formatting is wrong.
ACP

A
acpan 1/22/2020

Just checked with log and print that:
date('Y-m-d', strtotime('2007-10-12 +1 month'));
is okay.
So the earlier date formating comment i have removed in order not to cause confusion for you.
Again log date variables and show it and you can tell if the date formatting is wrong.
ACP