If statement not working
Posted: Thu Nov 05, 2009 11:16 am
I am assigning a query to a variable, then I would like to execute that query ONLY if two variables ($a and $b) are equal. both variables are DECIMAL because they are dollar amounts.
I have the following script
I believe there is a problem with my IF statement, because $query6 is executed every single time, even if $a and $b are not equal. Perhaps with the == or quotes. From research I thought it might be because the variables are numbers(DECIMAL). Any guidance is appreciated.
I have the following script
Code: Select all
$query6="UPDATE table SET deduction = deduction + $amount, balance = balance - $amount WHERE number=$number";
if ($a == $b)
{
mysql_query($query6, $link) or die("query 6 has failed - " . mysql_errno() . ": " .
mysql_error());
echo "\$$amount was deducted from the district's balance. <br>\n";
} else {
echo "The balance for district $number was not changed. <br>\n";
}