Page 1 of 1

Proble with update query

Posted: Tue Jun 26, 2007 5:40 am
by bhavna
Hi

I am trying to update time in same row, but it's not updating negative time properly

can anyone tell me solution of this query?

mysql_query("update daily_timerecord set FLEX_BALANCE=ADDTIME(FLEX_BALANCE,SEC_TO_TIME($total)) where EMPLOYEE_ID=$id and UPDATE_DATE > '$date' and UPDATE_DATE <= CURDATE()")

in this query FLEX_BALANCE may have "-01:00:00" value but this query runs properly in phpmyadmin but not running through php code...

Thanks

Posted: Tue Jun 26, 2007 7:54 am
by superdezign
Are you getting an error?

Posted: Tue Jun 26, 2007 8:38 am
by bdlang
Make certain your $id, $total and $date variables have a value, and run your query this way:

Code: Select all

$sql= "
UPDATE daily_timerecord
SET FLEX_BALANCE = ADDTIME(FLEX_BALANCE,SEC_TO_TIME('$total'))
WHERE EMPLOYEE_ID=$id
 AND UPDATE_DATE > '$date'
 AND UPDATE_DATE <= CURDATE()
";

$result= mysql_query($sql) OR die( 'QUERY ERROR:<br />' .$sql. '<br />' .mysql_error() );
Note the quotation marks around $total - not clear as to what sort of data that is.