This topic is locked

update last modified date/time

8/13/2007 11:49:56 AM
PHPRunner General questions
Allenh author

I'm trying to update the timestamp for a record, ie. everytime it's modified, the current time is added/updated.

My fields are:
tablea: table name

last_update: timestamp
event: before record update
global $conn;

$strSQLInsert = "update tablea

set last_update = now()

where IDFIELD = '".$values["IDFIELD"]."'";

db_exec($strSQLInsert,$conn);
return true;
Do I need to set the properties for update_table with custom code of now()? - I've tried that too, without success.

Not sure where I'm going wrong on this one.

H
hugolesme 8/13/2007

This is a example how to update the Id and login of user (timestamp) time e date, host and address
global $conn;
$strSQLtmp = "select idusuario from usuario where login = '".$_SESSION['UserID']."'";
$rstmp = db_query($strSQLtmp,$conn);
$datatmp = db_fetch_numarray($rstmp);
$values["loginmod"] = $_SESSION["UserID"];
$values["modificacion"] = 'now';
if ($datatmp)

$values["idusuariomod"] = $datatmp[0];http://www.asprunner.com/forums/index.php?showtopic=5981&st=0&gopid=20396&#

Complete Edit
$values["remote_addrmod"] = $_SERVER['REMOTE_ADDR'];
if(!$_SERVER['REMOTE_HOST'])

$host = gethostbyaddr($_SERVER['REMOTE_ADDR']);
else

$host = $_SERVER['REMOTE_HOST'];
$values["remote_hostmod"] = $host;
return true;

I'm trying to update the timestamp for a record, ie. everytime it's modified, the current time is added/updated.

My fields are:
tablea: table name

last_update: timestamp
event: before record update
global $conn;

$strSQLInsert = "update tablea

set last_update = now()

where IDFIELD = '".$values["IDFIELD"]."'";

db_exec($strSQLInsert,$conn);
return true;
Do I need to set the properties for update_table with custom code of now()? - I've tried that too, without success.

Not sure where I'm going wrong on this one.