tags:

views:

93

answers:

1

Hello i got this error

its the

$birthDay = date("d", $alder); $birthYear = date("Y", $alder);

i dont know what it is

here is my code

        //Dag
            $maxDays = 31;
            $birthDay = date("d", $alder);
            echo '<select name="day">';
            echo '<option value="">Dag</option>';
            for($i=1; $i<=$maxDays; $i++)
            {
            echo '<option '; if($birthDay == $i){ echo 'selected="selected"'; } echo ' value="'.$i.'">'.$i.'</option>';
            }
            echo '</select>';

        //Måned
            echo '<select name="month">';
            $birthMonth = date("m", $alder);
            $aManeder = 12;
            echo '<option value="">Måned</option>';
            for($i = 1; $i <= $aManeder; $i++)
            {
            echo '<option '; if($birthMonth == $i) { echo 'selected="selected"'; } echo ' value="'.$i.'">'.$ManderArray[$i].'</option>';
            }
            echo '</select>';


        //År
            $startYear = date("Y");
            $endYear = $startYear - 30;
            $birthYear = date("Y", $alder);
            echo '<select name="year">';
            echo '<option value="">år</option>';
            while($endYear <= $startYear)
            {
            echo '<option '; if($birthYear == $endYear) { echo 'selected="selected"'; } echo ' value="'.$endYear.'">'.$endYear.'</option>';
            $endYear++;
            }
            echo '</select>';
A: 

The error message says it all: parameter 2 ($alder) does not have a valid numeric value. Insert the following line right before the erroneous line and trace back the origin of the current value of $alder:

var_dump($alder);

You could initialize $alder with 0 or microtime(true) so that date() gets a valid parameter. But if you set it to an empty string ('') you will always get the above error message.

StefanMacke
then a user create a new user the $alder is empty, so it cant be emty?
Simon