[SOLVED]Preventing TIMESTAMP from updating

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
blacksnday
Forum Contributor
Posts: 252
Joined: Sat Jul 30, 2005 6:11 am
Location: bfe Ohio :(

[SOLVED]Preventing TIMESTAMP from updating

Post by blacksnday »

When you have rows that use a Timestamp, how do you stop it
from updating the date when the row is updated?

I know if using something like phpMyAdmin you just unselect the timestamp field,
but my question concerns when writing an update/edit script for a website-based admin.

The current update query I am using in my script is

Code: Select all

$query="UPDATE news  SET name='$ud_first', news='$ud_last' WHERE id='$ud_id'";
Would something like

Code: Select all

$query="UPDATE news  SET name='$ud_first', news='$ud_last', date='' WHERE id='$ud_id'";
work to stop the timestamp from changing when being updated?
well, scratch that... doing it that way results in an empty timestamp.

hmm.. how to update and keep the timestamp the same as the original?
User avatar
blacksnday
Forum Contributor
Posts: 252
Joined: Sat Jul 30, 2005 6:11 am
Location: bfe Ohio :(

Post by blacksnday »

I got it fixed :)

Just added stuff needed to pull the date from the database then insert when updated
and no more changing timestamps !
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you don't even have to select the timestamp.. simply setting it to itself during the update will keep it in the original form.
Post Reply