I have a page that when data is posted to it inserts the value into my DB.
Im trying to get a sum of all the values from the DB before hand, then insert the value, and then take the SUM away from the value inserted if this makes sense?
$totalquery = mysql_query("SELECT SUM(bill) FROM `outgoings` WHERE outgoings.user_id = '$uid'") or die(mysql_error());
$totalresult = mysql_fetch_array($totalquery);
$uid = $_SESSION['oauth_id'];
$id = $_POST['col-id'];
$sanitized_monthly_income = mysql_real_escape_string($_POST['monthly-income']);
mysql_query("INSERT INTO income (id, user_id, monthly_income) VALUES ('$id', '$uid', '$sanitized_monthly_income') ON DUPLICATE KEY UPDATE monthly_income = VALUES(monthly_income)");
echo $sanitized_monthly_income - $totalresult["SUM(bill)"];
This is the error I receive though
Notice: Undefined variable: uid in update_salary.php on line 18