1

Here's the code I'm trying to echo the data from the clearance form table if the $today date matches with the $expirydate from the clearance table

$today = date("Y-m-d");
$expirydate = $row->currentdate; //from database

$today_time = strtotime($today);
$expire_time = strtotime($expirydate);

if ($expire_time < $today_time) {
    echo '(body....) ';
Nico Haase
  • 11,420
  • 35
  • 43
  • 69
chad
  • 13
  • 2
  • Does this answer your question? [Reference - What does this error mean in PHP?](https://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php) – Nico Haase Mar 10 '22 at 17:08
  • Also, please do not use irrelevant tags - your question does not contain any code related to MySQL – Nico Haase Mar 10 '22 at 17:09

1 Answers1

0

The arrow -> is also called the object operator and is used to access properties or non-static methods on an object of a class.


You should debug your code to check the type of $row because it obviously is not an object that has an property currentdate. Because of this the error you got was thrown.


As a bonus tip you should also check out the null-safe operator which checks for null

Quote from https://wiki.php.net/rfc/nullsafe_operator:

When the left hand side of the operator evaluates to null the execution of the entire chain will stop and evalute to null. When it is not null it will behave exactly like the normal -> operator.

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
WebDevPassion
  • 422
  • 1
  • 4
  • 12