944,209 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 2557
  • PHP RSS
Sep 17th, 2007
0

timestamp help?

Expand Post »
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['time'];

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.
Similar Threads
Reputation Points: 27
Solved Threads: 0
Light Poster
danarashad is offline Offline
43 posts
since Jan 2007
Sep 17th, 2007
0

Re: timestamp help?

What is the error? do this

mysql_query($sql) or die(mysql_error());
It will tell you the error
Sponsor
Reputation Points: 520
Solved Threads: 268
Code Monkey
ShawnCplus is offline Offline
1,564 posts
since Apr 2005
Sep 18th, 2007
0

Re: timestamp help?

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())";
Reputation Points: 10
Solved Threads: 1
Newbie Poster
shovels is offline Offline
11 posts
since Sep 2007
Sep 18th, 2007
0

Re: timestamp help?

thanks i've got it fixed, i just used the now() function
Reputation Points: 27
Solved Threads: 0
Light Poster
danarashad is offline Offline
43 posts
since Jan 2007
Sep 18th, 2007
0

Re: timestamp help?

Cool, glad I could be of help.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
shovels is offline Offline
11 posts
since Sep 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Php
Next Thread in PHP Forum Timeline: How do I hide email recepients?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC