Skip to main content
Inspiring
March 7, 2007
Question

current_timestamp on Update (k)

  • March 7, 2007
  • 7 replies
  • 521 views
I have am using the Record Update Form Wizard server behavior in
Dreamweaver to update the records in my mySQL database.

It works great except for the part of my table with the timestamp in
phpmyadmin here are the settings:

Field: DateEnteredUpdated
Type: timestamp
Collation:
Attributes: on update current_timestamp
Null: No
Default: current_timestamp
Extra:


I used the Insert Wizard and it will enter the current time, but the
update won't. Any tips?

-Kirk

This topic has been closed for replies.

7 replies

Inspiring
March 8, 2007
W. Kirk Lutz wrote:
> You sir, are the Man!
>
> Date now updates. I removed the timestamp field from my PHP page and
> mySQL did the rest.
>
> Thank you very much.

Glad it was sorted so easily.

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Inspiring
March 8, 2007
You sir, are the Man!

Date now updates. I removed the timestamp field from my PHP page and
mySQL did the rest.

Thank you very much.

-Kirk

David Powers wrote:
> W. Kirk Lutz wrote:
>> The update page I've created has two record sets that pull in two
>> tables. One contains the timestamp the other is for a dropdown options
>> menu created from the non-timestamped table.
>>
>> Could the problem be linked to the Sessions thing from my other post?
>
> No, the two issues are completely separate.
>
> It sounds as though your update command is sending the timestamp from
> your web page back to the table. That simply reinserts the existing
> value. As I said before, you should not insert a value in the timestamp
> column. MySQL updates the timestamp automatically.
>
Inspiring
March 8, 2007
W. Kirk Lutz wrote:
> The update page I've created has two record sets that pull in two
> tables. One contains the timestamp the other is for a dropdown options
> menu created from the non-timestamped table.
>
> Could the problem be linked to the Sessions thing from my other post?

No, the two issues are completely separate.

It sounds as though your update command is sending the timestamp from
your web page back to the table. That simply reinserts the existing
value. As I said before, you should not insert a value in the timestamp
column. MySQL updates the timestamp automatically.

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Inspiring
March 8, 2007
Okay, I have one database that contains 3 tables. Only one table has a
timestamp in it.

The update page I've created has two record sets that pull in two
tables. One contains the timestamp the other is for a dropdown options
menu created from the non-timestamped table.

Could the problem be linked to the Sessions thing from my other post?

-Kirk

David Powers wrote:
> W. Kirk Lutz wrote:
>> Little confused. Are you talking about the mySQL table? Or the table
>> on on the web page where the update is occurring?
>>
>> It was the last field I thought of when I built the database table,
>> but it is the only timestamp in the database.
>
> I'm talking about the database table.
>
> It sounds as though you're getting a little mixed up about the
> difference between a database and a database table. A database can have
> many tables, and each table can have one or more timestamp columns. It
> doesn't matter where it is in the table, but the first column that uses
> a timestamp data type is normally updated automatically.
>
> MySQL 5.0 lets you specify a different timestamp column to update
> automatically, but since you have only one in the table, there's no need
> to go into the complexities of multiple timestamps.
>
Inspiring
March 8, 2007
W. Kirk Lutz wrote:
> Little confused. Are you talking about the mySQL table? Or the table on
> on the web page where the update is occurring?
>
> It was the last field I thought of when I built the database table, but
> it is the only timestamp in the database.

I'm talking about the database table.

It sounds as though you're getting a little mixed up about the
difference between a database and a database table. A database can have
many tables, and each table can have one or more timestamp columns. It
doesn't matter where it is in the table, but the first column that uses
a timestamp data type is normally updated automatically.

MySQL 5.0 lets you specify a different timestamp column to update
automatically, but since you have only one in the table, there's no need
to go into the complexities of multiple timestamps.

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Inspiring
March 8, 2007
Little confused. Are you talking about the mySQL table? Or the table on
on the web page where the update is occurring?

It was the last field I thought of when I built the database table, but
it is the only timestamp in the database.

-Kirk


David Powers wrote:
> W. Kirk Lutz wrote:
>> I used the Insert Wizard and it will enter the current time, but the
>> update won't. Any tips?
>
> As long as it's the first timestamp column in a table, it will
> automatically update whenever a record is changed. You don't need to
> enter any value for it. However, if the "update" doesn't result in any
> change to other columns (fields) the timestamp will not change. It's not
> the last time you ran an update query, but the last time anything changed.
>
Inspiring
March 8, 2007
W. Kirk Lutz wrote:
> I used the Insert Wizard and it will enter the current time, but the
> update won't. Any tips?

As long as it's the first timestamp column in a table, it will
automatically update whenever a record is changed. You don't need to
enter any value for it. However, if the "update" doesn't result in any
change to other columns (fields) the timestamp will not change. It's not
the last time you ran an update query, but the last time anything changed.

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/