the above is correct.
Moreover, you don't need to play with quotes the way you do, and your SQL phrase is not closed.
IMHO, it should read :
$sql1 = "UPDATE custpayments SET depcardbal = depcardbal -$totcardsubtotal, projacctbal = projacctbal - $totprojsubtotal, bankacctbal = bankacctbal - $bankacctwithdraw, transfacctbal = transfacctbal - $transfacctwithdraw, transactionstatus = '2' WHERE paytransacid = $paytransacid;";
moreover, your variables are empty. Given they're numeric, they should be initialized explicitly at the start of your program/script (a good habit I inherited from Pascal).
A workaround#1 is to use the 0 trick
A workaround#2 is to add before the query line above :
$totcardsubtotal=(isset($totcardsubtotal)?(($totcardsubtotal>0)?$totcardsubtotal:0):0); // repeat this line for all variables
$sql1 = "UPDATE custpayments ...
A workaround#3 is to explictly cover the case in your SQL statement, but this is a bit overkill :
$sql1 = "UPDATE custpayments SET depcardbal = depcardbal - case when $totcardsubtotal is not null then $totcardsubtotal else 0 end,
best regards