How to add NOW() for DATETIME in $strQuery = INSERT INTO..?
Posted: Mon Oct 17, 2011 7:57 am
I need to capture the DATETIME field from an sql table and have gone blank on how to add the NOW() value to my insert code. Any help much appreciated Code is as follows:
Code: Select all
/* build the insert query */
$strQuery = "INSERT INTO table_name ".
" ( q1, q2, q3, q4, q5, q6, q7, q8, q9, q10, q11, q12, q13, q14, q15, q16, q17, q18, q19,dt ) ".
" VALUES ".
" ( '$frmq1', ".
" '$frmq2', ".
" '$frmq3', ".
" '$frmq4', ".
" '$frmq5', ".
" '$frmq6', ".
" '$frmq7', ".
" '$frmq8', ".
" '$frmq9', ".
" '$frmq10', ".
" '$frmq11', ".
" '$frmq12', ".
" '$frmq13', ".
" '$frmq14', ".
" '$frmq15', ".
" '$frmq16', ".
" '$frmq17', ".
" '$frmq18', ".
" '$frmq19') ";
/* catch results */
$res = mysql_query($strQuery, $dbc)
or die("<hr>Query failed : <br>[".mysql_errno($dbc)."] ".mysql_error($dbc)."<hr>\n");
if($res === true) {
echo "Thank you for your participation. ".mysql_affected_rows($dbc). " record(s) inserted.";
}
/* clean up */
mysql_close($dbc);
?>