$unpaid1="SELECT t.id, t.year, t.property_id, COALESCE(t.amount,0) AS amount FROM tax_amount t WHERE t.status = 'unpaid' ORDER BY t.year";
$resultpropertyunpaid1 = $db->query($unpaid1);
while($row = $resultpropertyunpaid1->fetch_assoc()){ 
    $PropertyUnpaid1 = $row['unpaid'];
}

When I'm making a new property and put the amount the error will show but after I paid the total amount the error will not show.

You have this SQL query that retrieves rows from a table. Then, you have this code:

while($row = $resultpropertyunpaid1->fetch_assoc()){ 
    $PropertyUnpaid1 = $row['unpaid'];
}

There, you’re saying for each row retrieved from the database, do the things in this loop. Assign the value of the unpaid column in the retrieved dataset to the property unpaid variable.

But the thing is, you haven’t created the row yet, so the record doesn’t exist yet, so the unpaid column has no value. That’s why you’re getting the error before you insert the data but not after.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.