I set $date as the current time, and when i insert it into the database it appears as a long decimal.
ex. 0.000059642147117296
Here’s the code:
HTML
<form id="comments" action="<?=site_url('headquarters/scopeSummary')?>" method="POST">
<textarea name="comment" cols="70" rows="5"></textarea>
<input type="hidden" name="scopeId" value="<?=$id?>" />
<input type="hidden" name="user" value="<?=$user?>" />
<br />
Mark as important?<input type="checkbox" name="important" value="yes" />
<input type="submit" value="Submit" name="submit" />
</form>
PHP
if ($comment) {
$date = date('n/d/Y', time());
$comQuery = $this->db->query('INSERT INTO scope_comments VALUES(NULL, "'. $scopeId .'", "'. $comment .'", "'. $user .'", "", "", '. $date .', "'. $gravity .'")');
}
all the values being inserted are set. They are not the problem. Only the $date is messing up. Im using codeigniter and phpmyadmin.
You neglected to quote the date value, so the system is computing something like 3/25/2012 (which is the
0.00005642147117296you are seeing).You are also specifying the date in the wrong format. It MUST be in the
Y-m-dformat.Finally, chances are your database field is not defined as a date, so make sure to correct that table definition.