Proble with update query

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
bhavna
Forum Newbie
Posts: 1
Joined: Tue Jun 26, 2007 5:31 am

Proble with update query

Post 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
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Are you getting an error?
bdlang
Forum Contributor
Posts: 395
Joined: Tue May 16, 2006 8:46 pm
Location: Ventura, CA US

Post 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.
Post Reply