User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 456,488 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,735 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 824 | Replies: 4
Reply
Join Date: Jan 2007
Posts: 6
Reputation: danarashad is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
danarashad danarashad is offline Offline
Newbie Poster

timestamp help?

  #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.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2005
Location: New York state
Posts: 487
Reputation: ShawnCplus will become famous soon enough ShawnCplus will become famous soon enough 
Rep Power: 5
Solved Threads: 73
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey

Re: timestamp help?

  #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 z+*
Reply With Quote  
Join Date: Sep 2007
Posts: 11
Reputation: shovels is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
shovels shovels is offline Offline
Newbie Poster

Re: timestamp help?

  #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  
Join Date: Jan 2007
Posts: 6
Reputation: danarashad is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
danarashad danarashad is offline Offline
Newbie Poster

Re: timestamp help?

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

Re: timestamp help?

  #5  
Sep 18th, 2007
Cool, glad I could be of help.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 3:09 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC