timestamp help?

Reply

Join Date: Jan 2007
Posts: 21
Reputation: danarashad is an unknown quantity at this point 
Solved Threads: 0
danarashad's Avatar
danarashad danarashad is offline Offline
Newbie Poster

timestamp help?

 
0
  #1
Sep 17th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 1,404
Reputation: ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light 
Solved Threads: 225
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey

Re: timestamp help?

 
0
  #2
Sep 17th, 2007
What is the error? do this

mysql_query($sql) or die(mysql_error());
It will tell you the error
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 11
Reputation: shovels is an unknown quantity at this point 
Solved Threads: 1
shovels shovels is offline Offline
Newbie Poster

Re: timestamp help?

 
0
  #3
Sep 18th, 2007
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())";
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 21
Reputation: danarashad is an unknown quantity at this point 
Solved Threads: 0
danarashad's Avatar
danarashad danarashad is offline Offline
Newbie Poster

Re: timestamp help?

 
0
  #4
Sep 18th, 2007
thanks i've got it fixed, i just used the now() function
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 11
Reputation: shovels is an unknown quantity at this point 
Solved Threads: 1
shovels shovels is offline Offline
Newbie Poster

Re: timestamp help?

 
0
  #5
Sep 18th, 2007
Cool, glad I could be of help.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC