Since MySQL evidently cannot automatically insert the function now() in a datetime field in adding new records like some other databases, based on comments, I\'m explicitly tryi
What about SYSDATE() ?
<?php
$db = mysql_connect('localhost','user','pass');
mysql_select_db('test_db');
$stmt = "INSERT INTO `test` (`first`,`last`,`whenadded`) VALUES ".
"('{$first}','{$last}','SYSDATE())";
$rslt = mysql_query($stmt);
?>
Look at Difference between NOW(), SYSDATE() & CURRENT_DATE() in MySQL for more info about NOW() and SYSDATE().
NOW() normally works in SQL statements and returns the date and time. Check if your database field has the correct type (datetime). Otherwise, you can always use the PHP date() function and insert:
date('Y-m-d H:i:s')
But I wouldn't recommend this.
You forgot to close the mysql_query command:
mysql_query("INSERT INTO users (first, last, whenadded) VALUES ('$first', '$last', now())"
);
Note that last parentheses.