Timestamp Problem when updating...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
JPlush76
Forum Regular
Posts: 819
Joined: Thu Aug 01, 2002 5:42 pm
Location: Los Angeles, CA
Contact:

Timestamp Problem when updating...

Post 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!
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

What does your update script look like?

Mac
JPlush76
Forum Regular
Posts: 819
Joined: Thu Aug 01, 2002 5:42 pm
Location: Los Angeles, CA
Contact:

Post 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&#1111;"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'");
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

how is the table set up? what kind of function is "query_db", i don't see it in the manual?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Have you tried removing:

Code: Select all

user_join = $oldjoin,
from your UPDATE statement?

Mac
JPlush76
Forum Regular
Posts: 819
Joined: Thu Aug 01, 2002 5:42 pm
Location: Los Angeles, CA
Contact:

Post 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) 
&#123; 
 dbconnect(); 
 return @mysql_query($query); 
&#125;

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
JPlush76
Forum Regular
Posts: 819
Joined: Thu Aug 01, 2002 5:42 pm
Location: Los Angeles, CA
Contact:

Post 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"))
  &#123;
and here is how the field is setup in my table

Code: Select all

user_join  timestamp(14)   Yes  NULL
JPlush76
Forum Regular
Posts: 819
Joined: Thu Aug 01, 2002 5:42 pm
Location: Los Angeles, CA
Contact:

Post 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&#39;m naughty, are you naughty?'>smurf</span>?
User avatar
sam
Forum Contributor
Posts: 217
Joined: Thu Apr 18, 2002 11:11 pm
Location: Northern California
Contact:

Post by sam »

Ah, such is the reasons I just store my timestamps in an INT field.
EricS
Forum Contributor
Posts: 183
Joined: Thu Jul 11, 2002 12:02 am
Location: Atlanta, Ga

I didn't know that either

Post by EricS »

I didn't know that either, but I'm glad you hit the wall first! :)
JPlush76
Forum Regular
Posts: 819
Joined: Thu Aug 01, 2002 5:42 pm
Location: Los Angeles, CA
Contact:

Post by JPlush76 »

lol eric, glad I could help!
hehe
Post Reply