The SQL statement is
mysql_query("update mytable
set duration=floor(min(max(TIME_TO_SEC(TIMEDIFF(NOW(), moment))/60,5),600))
where taskid='$taskid' and memberid='$memberid'")or die(mysql_error());
and the error message is
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '5),600)) where taskid='4' and memberid='5'' at line 1