Please help I have been trying to insert a timestamp field into a DB. But to no avail.
Here's my code.
I am using a hidden field.
<input type="hidden" value="<? echo date("m-j-y g:i:s A"); ?>" name="time" />

Then on my action page, I do the following.
$stime=$_POST;

then my insert statement looks like.
$sql="INSERT INTO $tbl_name(username, password, level, email,fname,lname,time)VALUES('$uname', '$pword', '$level','$email','$fname','$lname','$stime')";

I can insert without the time, but i need that. And i need it to be passed from a form field.
My DB set up is.
Column name of time. type is timestamp.

When I insert i receive an error. thats all it says.

What is the error? do this mysql_query($sql) or die(mysql_error()); It will tell you the error

Why not just add a timestamp to the SQL statement?

I would also try to avoid using such names as time, date, etc for field names in a databases as this can cause problems.

For example:
$sql="INSERT INTO $tbl_name(username, password, level, email,fname,lname,time)VALUES('$uname', '$pword', '$level','$email','$fname','$lname', Now())";

thanks i've got it fixed, i just used the now() function

Cool, glad I could be of help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.