What is the proper php/mySQL syntax to insert a date/timestamp into a text column of mysql table using insert command
Posted on 2008-11-14
I've been trying to insert a record into a table using some values from a form, which was working until
i tried adding a timestamp field, it only seems to work if i put a static string in it. I though the code below should work, but it doesn't. Here is an example string that is contained in the variable today
"November 14, 2008, 8:46 am"
I figured maybe my problem is on the comma's or the colon, but don't know what to do about it.
$today = date("F j, Y, g:i a");
$query = "insert into myTable values (NULL,$today)";
$result = $db->query($query);
I also tried using SELECT NOW(); which works on the command line to mySQL, but again don't know how to syntax it correctly to be used as an input to the insert statement
The column i'm trying to insert it into is defined as char(30)