Page 1 of 1
Timestamp Problem when updating...
Posted: Wed Aug 14, 2002 12:42 pm
by JPlush76
Hey all, I'm writing an update program for users to update their own account info, well I have a field called user_join and its a timestamp of the time they joined the site
well everytime I go to update that record it updates that field as well and wipes out the original join date
also I tried to make a hidden field capturing the old date then updating that field with the old date but that didn't work either
any thoughts? thanks!
Posted: Wed Aug 14, 2002 12:44 pm
by twigletmac
What does your update script look like?
Mac
Posted: Wed Aug 14, 2002 12:57 pm
by JPlush76
actually I don't know what changed but it works now
I pass a hidden field with the oldtimestamp record and update the field when processed...
is there a better way to do that though? seems like a wasted step having to update a field that should never change
Code: Select all
<form method="post" action="st_edit2.php">
<input type="hidden" name="oldjoin" value="<? echo ($rowї"user_join"]); ?>">
Code: Select all
$result = query_db("update user set user_first = '$firstname' , user_join = $oldjoin, user_email = '$email' where user_uname = '$valid_user'");
Posted: Wed Aug 14, 2002 1:00 pm
by hob_goblin
how is the table set up? what kind of function is "query_db", i don't see it in the manual?
Posted: Wed Aug 14, 2002 1:02 pm
by twigletmac
Have you tried removing:
from your UPDATE statement?
Mac
Posted: Wed Aug 14, 2002 1:06 pm
by JPlush76
actually it doesn't work again now
looks like when I'm logged in my session and update it works fine... but lets say I close that browser and log back in, it doesn't work
the query_db function is a func I made for quick database calls
Code: Select all
//***** QUERY MYSQL RESULTS
function query_db($query)
{
dbconnect();
return @mysql_query($query);
}
that works fine, been using it forever... just can't figure out this damn timestamp thing... yea mac originally I didn't have that update user_join statement but it didn't work then either
Posted: Wed Aug 14, 2002 1:08 pm
by JPlush76
here is what I have at the top of the page:
Code: Select all
session_start();
//***** INCLUDE GLOBAL MASTER FILES
include ("includes/main.php");
include ("includes/newfunc.php");
if (session_is_registered("valid_user"))
{
and here is how the field is setup in my table
Posted: Wed Aug 14, 2002 1:27 pm
by JPlush76
AHHHHHHHHHH well here is something I didn't know that I just read in my MYSQL book:
The first timestamp column in your row will always be updated when added or updated!
so when I added a timestamp column before user_join, it now works
aint that some <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span>?
Posted: Wed Aug 14, 2002 1:57 pm
by sam
Ah, such is the reasons I just store my timestamps in an INT field.
I didn't know that either
Posted: Wed Aug 14, 2002 2:01 pm
by EricS
I didn't know that either, but I'm glad you hit the wall first!

Posted: Wed Aug 14, 2002 7:22 pm
by JPlush76
lol eric, glad I could help!
hehe