adding month to duedate

1Tsme1941

Member
Hi, I have a database file with records including "duedates" and want to update them at end of
month. I have researched this and make no sense of manuals.
I tried this:
------------
<?php
$servername='localhost';
$username='root';
$password='';
$dbname = "prerentdb";
$conn=mysqli_connect($servername,$username,$password,"$dbname");
if(!$conn){
die('Could not Connect My Sql:' .mysql_error());
}
if(count($_POST)>0) {
$amtpaid='amtpaid';
$amtdue='amtdue';
$duedate = strtotime(date("Y-m-d", strtotime($duedate)) . " +1 month"); // line 13
echo $duedate;
$prevbal='prevbal';
$latechg='latechg';
$secdep='secdep';
$damage='damage';
$courtcost='courtcost';
$nsf='nsf';
$hudpay='hudpay';
$datepaid='datepaid';
$paidsum='paidsum';
$Comment='Comment';

mysqli_query($conn,"UPDATE payfile set
id='" . $_POST['id'] . "',tenant='" . $_POST['tenant'] . "', unit='" . $_POST['unit'] . "',
amtpaid='" . $_POST['amtpaid'] . "' , duedate='" . $_POST['duedate'] . "',
prevbal='" . $_POST['prevbal'] . "', latechg='" . $_POST['latechg'] . "',
secdep='" . $_POST['secdep'] . "' , damage='" . $_POST['damage'] . "',
courtcost='" . $_POST['courtcost'] . "', nsf='" . $_POST['nsf'] . "', hudpay='" . $_POST['hudpay'] . "',
datepaid='" . $_POST['datepaid'] . "', paidsum='" . $_POST['paidsum'] . "',
comment='" . $_POST['comment'] . "'
WHERE id='" . $_POST['id'] . "'");
$message = "Record Modified Successfully";
}
-------------------
and got this:
Notice: Undefined variable: duedate on line 13
2674800
--------------
Please help.
 

1Tsme1941

Member
I tried this:
------------
<?php
$servername='localhost';
$username='root';
$password='';
$dbname = "prerentdb";
$conn=mysqli_connect($servername,$username,$password,"$dbname");
if(!$conn){
die('Could not Connect My Sql:' .mysql_error());
}
if(count($_POST)>0) {
$amtpaid='amtpaid';
$amtdue='amtdue';
$duedate='duedate';
$prevbal='prevbal';
$latechg='latechg';
$secdep='secdep';
$damage='damage';
$courtcost='courtcost';
$nsf='nsf';
$hudpay='hudpay';
$datepaid='datepaid';
$paidsum='paidsum';
$Comment='Comment';

$duedate = strtotime(date("Y-m-d", strtotime($duedate)) . " +1 month");
//echo $duedate;

mysqli_query($conn,"UPDATE payfile set
id='" . $_POST['id'] . "',tenant='" . $_POST['tenant'] . "', unit='" . $_POST['unit'] . "',
amtpaid='" . $_POST['amtpaid'] . "' , duedate='" . $_POST['duedate'] . "', // line 30
prevbal='" . $_POST['prevbal'] . "', latechg='" . $_POST['latechg'] . "',
secdep='" . $_POST['secdep'] . "' , damage='" . $_POST['damage'] . "',
courtcost='" . $_POST['courtcost'] . "', nsf='" . $_POST['nsf'] . "', hudpay='" . $_POST['hudpay'] . "',
datepaid='" . $_POST['datepaid'] . "', paidsum='" . $_POST['paidsum'] . "',
comment='" . $_POST['comment'] . "'
WHERE id='" . $_POST['id'] . "'");
$message = "Record Modified Successfully";
}
-------------------
and got this:
Notice: Undefined index: duedate in C:\xampp\htdocs\property\refresh_process.php on line 30
--------------
 

Cromewell

Administrator
Staff member
You need to read and understand the error message.

Figure out where the issue is, you have partially done this by finding line 30. But that is not all the error tells you, it gives you enough information to know exactly what part of the line is at fault. Undefined index means you are trying to access part of an array that is not there. "$_POST['duedate']" is the offending code.
 
Top