Condition is wrong, it should have two equals to signs ==
if($row['posted'] == date('j-n-Y'))
Please Note that one equal to sign is for assignment, it means that
$row['posted'] = date('j-n-Y')
The above code will assign the value of date('j-n-Y')
into $row['posted']
And your assignment will do nothing but just return true
, so every time it will go into the if condition block
where as the two equals to signs ==
are use for compression. so in your condition with double equals to, the code will only go into the if condition block when your $row['posted']
is equal to date('j-n-Y')
NOTE: mysql_*
functions are Officially deprecated (as of PHP 5.5. It's likely to be removed in the next major release.)
you need to have a look at this Why shouldn't I use mysql_* functions in PHP?