Jump to content

Checkdate() Error


shank888

Recommended Posts

Hi.

 

Every time I go and submit my form and try to verify a users birthdate uisng checkdate() i always get error:

 

Warning: checkdate() expects parameter 1 to be long, string given in FILENAME/register2.php on line 78

 

my code is:

 

if (!checkdate($_POST['year'],$_POST['month'],$_POST['day'])) {
	print "<p>You have entered an invalid Birthdate </p>";	
    }

 

edit: Just want to know what this error means and how I may be able to fix it.

 

Thanx

 

Link to comment
https://forums.phpfreaks.com/topic/105159-checkdate-error/
Share on other sites

prolly depends what your putting through, but if you cover it with something like this:

if( (is_numeric($_POST['year'])) && (is_numeric($_POST['month'])) && (is_numeric($_POST['day'])) )
{
if (!checkdate(intval($_POST['year']),intval($_POST['month']),intval($_POST['day']))) {
	print "<p>You have entered an invalid Birthdate </p>";	
}
}
else
{
print "<p>Invalid input!</p>";	
}

 

 

Edit: added intval

Link to comment
https://forums.phpfreaks.com/topic/105159-checkdate-error/#findComment-538410
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.