0

I don't what is wrong but there's an error
Error: Incorrect date value: '' for column 'DateBirth' at row 1

I searched for answers but there seems nothing wrong with my code. I used date as datatype for date of birth.

my php script.

<?php
$m = $_POST["month"];
$d = $_POST["day"];
$y = $_POST["year"];
$datebirth = $y . $m . $d;

mysql_query("INSERT INTO StoreTbl (DateofBirth) values('$datebirth')", $con);
?>

Day and Year uses for loop

<?php
echo "<select name='day'>";

for ($i=0; $i<=30; $i++)
{
$day = 1 + $i;

echo "<option value = $day>" . $day ."</option>";
}
echo "</select>";


echo "<select name='year'>";

for($i=0; $i<=59; $i++)
{
$year = 2005 - $i;

echo "<option value = $year>" . $year . "</option>";
}
echo "</select>";

So what's wrong?

Edited by AngelicOne: n/a

2
Contributors
4
Replies
6
Views
6 Years
Discussion Span
Last Post by AngelicOne
0

I believe there's nothing wrong with my for loop too.

When I view the source code it's fine

<option value='31'>31</option>

Edited by AngelicOne: n/a

0

I tried that but

Error: Incorrect date value: '--' for column 'DateBirth' at row 1

0

I found out the problem. I'm running the PHP script everytime I load the page. So, I set the isset() function. I don't know exactly the fix but I do get it. Thanks. :p

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.