Hi, I just getting a series of zeros when I try and enter dates in my db, attached is my code.
Hope you can help.
<?php
/* connect to db */
$link_id = mysql_connect("localhost", "root", "");
mysql_selectdb("calendar",$link_id);
/* confirm form is posted */
if (isset($_REQUEST['send']))
{
/* set posted variables */
$title = $_POST['title'];
$description = $_POST['description'];
/* Check startdate is valid */
if (checkdate($_POST['startmonth'],$_POST['startday'],$_POST['startyear']) != NULL)
{
$startdate = $_POST['startyear']."-".$_POST['startmonth']."-".$_POST['startday'];
}
else
{
echo "startDate is null, please try again";
}
/* Check startdate is valid */
if (checkdate($_POST['endmonth'],$_POST['endday'],$_POST['endyear']) != NULL)
{
$enddate = $_POST['endyear']."-".$_POST['endmonth']."-".$_POST['endday'];
}
else
{
echo "endDate is null, please try again";
}
/* validate variables */
if(empty($title)) error_message("Enter a title");
if(empty($description)) error_message("Enter a description!");
$query = "INSERT INTO tblevent VALUES(NULL, $startdate, $enddate,
'$title', '$description', NULL)";
mysql_db_query("calendar", $query) or die("Failed Query of " . $query);
echo "INSERT INTO tblevent VALUES (NULL," . $startdate . "," . $enddate . ",'" . $title . "','". $description . "',NULL)";