#!/usr/bin/php -q answer(); $answeredtime = $agi->get_variable("ANSWEREDTIME"); $g = $answeredtime; $h = $agi->get_variable("clientfirst"); $i = $agi->get_variable("clientsecond"); $j = $agi->get_variable("clientrate"); $k = $agi->get_variable("credit"); $seconds = $g['data']; $first = $h['data']; $second = $i['data']; $credit = $k['data']; $cost = $j['data']; $A = bcsub( $seconds, $first ); $B = bcdiv($A, $second, 4); $C = ceil( $B ); $D = bcmul( $C, $second, 4 ); $E = bcadd( $D, $first ); $F = bcdiv( $cost, 60, 10); $total = bcmul( $F, $E, 4 ); $deduct = bcsub($credit, $total, 4); $agi->verbose($cost); connect_db(); $query1 = "update cardcustomer set credit='$deduct' where phone='$incoming_number' "; $query_result1 = @mysql_query($query1); ?>