The Problem…
If a user signs up for a free account, they are charged $2 plus $1 per pic they add. Or they can pay $5.95 for a full account. And so far everything works just fine. However… if a user say pays for a free account, uploads one pic… pays the $3… then later decides to upgrade… It tells them they only have to pay $2.95 because its taking the $3 they already paid into account. (its not supposed to) - also this is resulting in some cases where the account balance is reading negative, which then causes half the profile buttoms to vanish. (not real sure why) Anyway, I’ve looked at it until I am blue in the face, and I am pretty sure that if I can get it to stop deducting what they already previously paid when they first got the account when they upgrade, that the button problem will more or less fix itself.
This is the code used to calculate the balance… any ideas?
function calcBalance($id){
$accountType = mysql_result(mysql_query("Select custAccountType from customers where custID=$id"),0);
if ($accountType == 1){
$balance = "5.95";
}
else{
$sqlst = "Select * from pics inner join pets on petID=picPetID where petCustID='$id' and picDeleted=0";
//echo "<BR>" . $sqlst . "<BR>";
$pics = mysql_query($sqlst) or myerror("Getting Pic Count");
$picCount = mysql_num_rows($pics);
//echo $picCount . "***<BR>";
$balance = $picCount;
}
$paid = round(mysql_result(mysql_query("Select sum(payAmount) as paid from payments where payCustID='$id'"),0),2);
//echo "Paid: $paid<BR>";
$balance = $balance - $paid;
return $balance;