cornelombaard Posted December 18, 2008 Share Posted December 18, 2008 Nothing is shown with this code not even an error $today = date('d/m/y'); $checknow = checkdate(12, 18, 2008); if ($checknow = $today) { print "today's date is the " . $today; } else { print "Not today"; } Quote Link to comment https://forums.phpfreaks.com/topic/137537-what-is-wrong-with-this-code-since-i-dont-get-an-error/ Share on other sites More sharing options...
ngreenwood6 Posted December 18, 2008 Share Posted December 18, 2008 when you are comparing you need to do: if ($checknow == $today) The way you had it was telling it that $checknow was $today. You know that is going to return negative always right. Quote Link to comment https://forums.phpfreaks.com/topic/137537-what-is-wrong-with-this-code-since-i-dont-get-an-error/#findComment-718769 Share on other sites More sharing options...
Maq Posted December 18, 2008 Share Posted December 18, 2008 If that --^ doesn't solve the problem, we need to know what the checkdate function looks like... Quote Link to comment https://forums.phpfreaks.com/topic/137537-what-is-wrong-with-this-code-since-i-dont-get-an-error/#findComment-718775 Share on other sites More sharing options...
ngreenwood6 Posted December 18, 2008 Share Posted December 18, 2008 yeah I was thinking that was a built in function so it may return positive sorry about that but you do need to change the = to == Quote Link to comment https://forums.phpfreaks.com/topic/137537-what-is-wrong-with-this-code-since-i-dont-get-an-error/#findComment-718779 Share on other sites More sharing options...
Maq Posted December 18, 2008 Share Posted December 18, 2008 yeah I was thinking that was a built in function Ooops, it is... :-X Quote Link to comment https://forums.phpfreaks.com/topic/137537-what-is-wrong-with-this-code-since-i-dont-get-an-error/#findComment-718794 Share on other sites More sharing options...
ngreenwood6 Posted December 18, 2008 Share Posted December 18, 2008 There you go confusing me lol. Quote Link to comment https://forums.phpfreaks.com/topic/137537-what-is-wrong-with-this-code-since-i-dont-get-an-error/#findComment-718798 Share on other sites More sharing options...
Maq Posted December 18, 2008 Share Posted December 18, 2008 What exactly are you trying to accomplish? checkdate(12, 18, 2008) - all checkdate() does is return TRUE or FALSE depending if the date is valid... So this statement: if ($checknow = $today) is equivalent to: if($checknow = 18/12/08) Quote Link to comment https://forums.phpfreaks.com/topic/137537-what-is-wrong-with-this-code-since-i-dont-get-an-error/#findComment-718805 Share on other sites More sharing options...
ngreenwood6 Posted December 18, 2008 Share Posted December 18, 2008 No it's not because he is trying to compare them. He needs to use the ==. Quote Link to comment https://forums.phpfreaks.com/topic/137537-what-is-wrong-with-this-code-since-i-dont-get-an-error/#findComment-718814 Share on other sites More sharing options...
Maq Posted December 18, 2008 Share Posted December 18, 2008 No it's not because he is trying to compare them. He needs to use the ==. I know. My point is that even if he were using the == operator he would be comparing 2 different types. Boolean and string (the date). if($checknow == $today) Would be: if(TRUE == "18/12/08") ? Quote Link to comment https://forums.phpfreaks.com/topic/137537-what-is-wrong-with-this-code-since-i-dont-get-an-error/#findComment-718819 Share on other sites More sharing options...
ngreenwood6 Posted December 18, 2008 Share Posted December 18, 2008 ok I got you sorry I was misreading your post. So he should just try doing: if($checknow == "12/18/2008") Then he can figure out how he wants to evaluate his variables. Quote Link to comment https://forums.phpfreaks.com/topic/137537-what-is-wrong-with-this-code-since-i-dont-get-an-error/#findComment-718825 Share on other sites More sharing options...
Maq Posted December 18, 2008 Share Posted December 18, 2008 No, he would still be comparing boolean vs string... cornelombaard, you need to clarify what exactly you're trying to do here. I guess you're trying to see if the date is today and if it's valid. But where does this date come from? Quote Link to comment https://forums.phpfreaks.com/topic/137537-what-is-wrong-with-this-code-since-i-dont-get-an-error/#findComment-718828 Share on other sites More sharing options...
ngreenwood6 Posted December 18, 2008 Share Posted December 18, 2008 yeah sorry I meant to put it as : if($today == "12/18/2008") I am with Maq though if you tell us what you are trying to do maybe we can be of more assistance. Quote Link to comment https://forums.phpfreaks.com/topic/137537-what-is-wrong-with-this-code-since-i-dont-get-an-error/#findComment-718838 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.