jeppers Posted April 11, 2010 Share Posted April 11, 2010 <li> <input type="submit" name="submit" value="Send My Posting" /> </li> <?php echo $date; if ($_POST['submit']){ include ('mysql_connect.php'); $sql = "insert into date (dates) values ('$date')"; $result = @mysql_query($sql) or die (mysql_error()); //run query } else { } i am struggling with this error. i have created a dummy database which all i am trying to do is enter the date. which has been selected from pull down menu's i have concatenated them and stored them in a variable call $date. i run the query and i get this as an error message 2010 01 1 Incorrect date value: '2010 01 1' for column 'dates' at row 1 has anyone got any idea on what i am doing wrong. hear is the full code i am using <form action="pulldown.php" method="post"> <label for="date">Date</label> <?php //make the months array $months = array (1 => '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'); //make the days and years array $days = range (1, 31); $years = range (2010, 2012); //make the days pull down menu echo '<select name="days">'; foreach ($days as $key => $value) { echo "<option value=\"$value\">$value</option>\n"; } echo '</select>'; //make that months pull down menus echo '<select name="months">'; foreach ($months as $key => $value) { echo "<option value=\"$value\">$value</option>\n"; } echo '</select>'; //make the year pull down menu echo '<select name="years">'; foreach ($years as $key => $value) { echo "<option value=\"$value\">$value</option>\n"; } echo '</select>'; $days = strtolower($_POST['days']); $months = strtolower($_POST['months']); $years = strtolower($_POST['years']); //create a date variable $date = $years .' '. $months .' '. $days; ?> <li> <input type="submit" name="submit" value="Send My Posting" /> </li> <?php echo $date; if ($_POST['submit']){ include ('mysql_connect.php'); $sql = "insert into date (dates) values ('$date')"; $result = @mysql_query($sql) or die (mysql_error()); //run query } else { } ?> Quote Link to comment Share on other sites More sharing options...
jeppers Posted April 11, 2010 Author Share Posted April 11, 2010 please help my head is hurting Quote Link to comment Share on other sites More sharing options...
teamatomic Posted April 11, 2010 Share Posted April 11, 2010 The proper date format is yyyy-mm-dd HTH Teamatomic Quote Link to comment Share on other sites More sharing options...
jeppers Posted April 11, 2010 Author Share Posted April 11, 2010 thanks for the help. the problem was the format i had it trying to go in the database like so 2001 20 01 which was wrong when i entered the correct format being 2001-20-01 worked well Quote Link to comment 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.