I have two different queries and I just try to print the part of my query as bellow,
$dateSql="DATE(DATE_SUB(ec.membership_expires,INTERVAL 1 WEEK))";
echo "1 : (DATE(ec.last_reminder) < $dateSql and NOW() >= $dateSql)";
echo "2 : (DATE(ec.last_reminder)<$dateSql and NOW()>=$dateSql)";
and I will get two different results :
1 : (DATE(ec.last_reminder) < DATE(DATE_SUB(ec.membership_expires,INTERVAL 1 WEEK)) and NOW() >= DATE(DATE_SUB(ec.membership_expires,INTERVAL 1 WEEK)))
2 : (DATE(ec.last_reminder)=DATE(DATE_SUB(ec.membership_expires,INTERVAL 1 WEEK)))
Can someone explain why it happens?
It happens because you're looking the result in a browser, which treats
<DATE(DATE_SUB(ec.membership_expires,INTERVAL 1 WEEK)) and NOW()>
as a tag and just skips it since it's invalid.
What you need to do - is just to see source of the page, run it in a terminal or wrap the whole output in htmlspecialchars()
.
JSFiddle: http://jsfiddle.net/NnEL6/
Guess time:
You're viewing the result in a browser which interprets HTML. <FOO
means something in HTML, < FOO
doesn't...