I am writing a little database program that takes data from a HTML form and inserts in into a database. I am gaving trouble getting the date to post. I have read the manuel and even bought a book titled "PhP and MySQL" but I guess I am just not understanding something about the date functions or how PhP interacts with MySQL with respect to the date function. Here is a snippet of code in my progam. Can someone tell me what I need to do to get the currect date into my SQL database?:
<start snippet>
$marque = addslashes($marque);
$category = addslashes($category);
$title = addslashes($keyword);
$techtip = addslashes($techtip);
$thedate = date("Y m d");
//Note, the below echo does echo the date as yyyy-mm-dd
echo("<p>The date is ".$thedate."</p>");
// CONNECT TO THE DATABASE SERVER
$dbcnx = @mysql_connect("localhost", "myhost", "password");
if (!$dbcnx) {
echo("<p>Unable to connect to the database server at this time.</p>" );
exit();
}
// SELECT THE My DATABASE
if(!@mysql_select_db("techtips")){
echo( "<p>Unable to locate the Tech Tip database at this time.</p>" );
exit();
}
//INSERT DATA INTO DATABASE
$query = "INSERT INTO tips SET
member = '$membernumber',
date_col = '$thedate',
title = '$title',
marque ='$marque',
category = '$category',
tip = '$techtip'";
<end snippet>
Now, after executing this code, all the data goes into my DB as it should, except the date_col (which is in the date format in my D😎 just shows 0000-00-00 and NOT the date that I am trying to pass to it. WHat am I doing wrong?
Thanks,
Basil