Problem setting Date field in MySQL



Hello,
I am having an issue with creating a database record and saving dates into the record. I have a form the user
enter's dates. That form calls the 'updateArticle.php' file and to update or create a new recod. Currently I'm
only working on the create record side of the program right now. All of the field's are passed from the form to
the PHP program throught the $_POST method. After that I assign the $_Post variable to a standard PHP variable,
then create the query and execute it on the database. When I look at the new record in the database, all dates are
set to '0000-00-00'. I've attempted to use the Date() function and change the format of the dates to 'Y-m-d',
however that does not work either. I've included the code below, if there is anything unclear or any help anyone
can provide, please feel free to ask or email me. I've been pulling my hair out tring to figure out where I've
screwed this up. Thanks!!!

FYI, $_POST['subDate'], $_POST['pubDate'] all echo out to 05-25-2012. The third date (remDate) is left blank on
purpose. The last echo result in the below code is:
INSERT INTO `ARTICLES`(`id`, `title`, `sub_date`, `pub_date`, `rem_date`, `body`, `imgname`) VALUES (NULL,'','05-
25-2012','05-25-2012','','',NULL)
1

============CODE==============
$id = sanitizeString($_POST['id']);
$title = sanitizeString($_POST['title']);
$subDate = sanitizeString($_POST['subDate']);
$pubDate = sanitizeString($_POST['pubDate']);
$remDate = sanitizeString($_POST['remDate']);
$body = sanitizeString($_POST['body']);
$imgFileName = sanitizeString($_POST['imgFileName']);
$query = "INSERT INTO `ARTICLES`(`id`, `title`, `sub_date`, `pub_date`, `rem_date`, `body`, `imgname`)
VALUES (NULL,'$title','$subDate','$pubDate','$remDate','$body',NULL)";
$results = mysql_query($query);
echo $query."<br />".$results;
remove the @@ and replace with OO to get my email address.

Thanks!!!

--
--------------------------------- --- -- -
Posted with NewsLeecher v3.9 Final
Web @ http://www.newsleecher.com/?usenet
------------------- ----- ---- -- -

.



Relevant Pages

  • Re: Avoid GET method
    ... always use the POST method to update the database. ... Second, do not put a separate set of buttons against each entry, use a ... Put a checkbox against each entry so that the ...
    (comp.lang.php)
  • Re: Does Post method really update?
    ... I definately call the Post method for the ... The behaviour depends on the database you are working with. ... set True to force immediate writes to disk table. ...
    (comp.lang.pascal.delphi.misc)
  • Re: Problem setting Date field in MySQL
    ... I am having an issue with creating a database record and saving dates into the record. ... the PHP program throught the $_POST method. ...
    (comp.lang.php)
  • Re: Does Post method really update?
    ... is not in the database. ... I definately call the Post method for the ... and CachedUpdates is set to false for all of them. ... Phenton ...
    (comp.lang.pascal.delphi.misc)
  • Does Post method really update?
    ... I often find that test data I added a while ... is not in the database. ... I definately call the Post method for the ... Groete ...
    (comp.lang.pascal.delphi.misc)