?
Solved

checkdate not working?

Posted on 2011-10-23
6
Medium Priority
?
264 Views
Last Modified: 2012-05-12
Hi All:

What am I doing wrong here. Checkdate seems to return true and false at the same time. I know this is not possible....I have tried several ways now to assign true/false and make an "if"-decission based on the outcome.

I have been looking at this for nearly an hour now. I can't see what I am doing wrong. I am sure its something silly.....

Thanks,

T :-)
if (checkdate(10,23,2011) == false);
		{
		echo ("FALSE ");
		}
	
	
	if (checkdate(10,23,2011) == true);
		{
		echo ("TRUE ");
		}	
	
	var_dump(checkdate(10,23,2011));

        // outputs: FALSE TRUE bool(true)

Open in new window

0
Comment
Question by:kracklt
  • 3
  • 2
6 Comments
 
LVL 39

Expert Comment

by:Aaron Tomosky
ID: 37014402
Do ===
http://php.net/manual/en/language.operators.comparison.php
With only two = it doesn't need and actual true or false.
0
 

Author Comment

by:kracklt
ID: 37014428
Thanks aaron for your comment.

=== returns the same result.

=== is only making clear that the type returned is correct as well. Otherwise a 1 may sometimes be interpreted as true... or so I seem to remember.

Anyways, tried === and also tried assigning:
 $result = checkdate(10,23,2011)

and then testing the $result
if ($result == true)...

Same difference.

Any other ideas?

T
0
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 2000 total points
ID: 37014493
You have two extra ';' in your code above.  The ';' terminates a statement so I don't think the rest of your 'if' statement is considered part of it.  I would format it as below.
if (checkdate(10,23,2011) == false) {
                echo ("FALSE ");
                }
if (checkdate(10,23,2011) == true) {
                echo ("TRUE ");
                }       
        
var_dump(checkdate(10,23,2011));

Open in new window

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:kracklt
ID: 37014526
NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO!!!!!

I knew it was something completely silly!!!! HAHAHAH. I should go to bed or something.

Thank you Dave!!
0
 

Author Closing Comment

by:kracklt
ID: 37014528
Such a silly mistake. Thanks again for pointing it out.
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 37014900
You're welcome, happens to all of us.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
This article discusses how to implement server side field validation and display customized error messages to the client.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month14 days, 15 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question