How to insert TIMESTAMP into my MySQL table?
<p>In the MySQL table I have a field called date its type is called timestamp and the default is <code>CURRENT_TIMESTAMP</code>. However, if I leave the field blank in MySQL I get an error. When I try to insert something into it like <code>time()</code> I receive the date as <code>0000-00-00 00:00:00</code>.</p>
<pre><code>&lt;?php

    $name         = &quot;&quot;;
    $email        = &quot;&quot;;
    $subject      = &quot;&quot;;
    $comments     = &quot;&quot;;
    $nameError    = &quot;&quot;;
    $emailError   = &quot;&quot;;
    $subjectError = &quot;&quot;;
    $x            = 5;
    function filterData($data)
    {
        $data = htmlspecialchars($data);
        $data = stripslashes($data);
        return $data;
    }
    $connection = mysql_connect('host', 'user', 'pass');
    if (!$connection) {
        die('Could not connect: ' . mysql_error());
    }
    
    
    $select_database = mysql_select_db(&quot;contact&quot;);
    
    if (!$select_database) {
        echo &quot;could not select database &quot; . mysql_error();
        
    }
    if ($_SERVER[&quot;REQUEST_METHOD&quot;] == &quot;POST&quot;) {
        //handles the name 
        $name = filterData($_POST[&quot;name&quot;]);
        if (empty($name)) {
            $nameError = &quot;please don't leave the name field blank&quot;;
        }
        //handles the email
        $email = filterData($_POST[&quot;email&quot;]);
        if (empty($email)) {
            $emailError = &quot;please don't leave the email field blank&quot;;
        }
        
        //handles the subject
        $subject = filterData($_POST[&quot;subject&quot;]);
        if (empty($subject)) {
            $subjectError = &quot;please don't leave this field blank&quot;;
        }
        
        $comments = filterData($_POST[&quot;comments&quot;]);
        
    }
    
    $insertation = &quot;INSERT INTO contactinfo (name, email, subject, date, comments)
        VALUES ('$name', '$email', '$subject', '', '$comments')&quot;;
    
    $insertationQuery = mysql_query($insertation, $connection);
    
    if (!$insertationQuery) {
        echo &quot;Could not process your information &quot; . mysql_error();
    } else {
        echo &quot;Thank you for submitting the information&quot;;
    }
    
?&gt;
</code></pre>