now() in hidden form tag

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
AliasBDI
Forum Contributor
Posts: 286
Joined: Fri Nov 15, 2002 10:35 am
Location: Spring, TX, USA

now() in hidden form tag

Post by AliasBDI »

I have a table with a TIMESTAMP field. I want it to update the TIMEDATE each time the record has an UPDATE. So I added a hidden input type tag and put <? now(); ?> in the value with the column name in the name. The php is giving me an error. Am I not doing this correctly?

MySQL db by the way.
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

now() is a myssql function. If you are looking to do this in php check out [php_man]mktime[/php_man] [php_man]date[/php_man] and [php_man]time[/php_man].


When I insert dates I use the following query:

Code: Select all

<?php
$qry = "INSERT INTO TBL_NAME(ID,DTTM) VALUES (1,now())";
?>
AliasBDI
Forum Contributor
Posts: 286
Joined: Fri Nov 15, 2002 10:35 am
Location: Spring, TX, USA

another question

Post by AliasBDI »

Is there no way to declare it as a variable? Or call it from the server as a variable?
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

hawleyjr wrote: If you are looking to do this in php check out [php_man]mktime[/php_man] [php_man]date[/php_man] and [php_man]time[/php_man].
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

the first timestamp field in your row will automatically update when you issue an update call.
Post Reply