Hello,
I know this will be an easy fix--but as of now I'm banging my head
against the wall. I need a fresh perspective from the group to see
what my problem is:
This is a simple accounting application, and the code below is
checking to see if a user's withdraw request is greater than their
available balance:
$withdraw_reque st = $_REQUEST['withdraw_amoun t']; // 543.21
$withdraw_maxim um = $user['available_bala nce']; // 543.21
if($withdraw_re quest $withdraw_maxim um) {
echo "Insufficie nt funds.";
} else {
echo "Processing..." ;
}
In my application, both values are equal (543.21), but
$withdraw_reque st $widthdraw_maxi mum still evaluates to TRUE, and
thus shows "Insufficie nt funds." If the two values are whole numbers,
like "543", then they evaluate the way I expect them to.
I've tried everything I can think of, like
$withdraw_reque st = floatval($_REQU EST['withdraw_amoun t']);
$withdraw_maxim um = floatval($user['available_bala nce']);
as well as doing an "isnumeric" check on both values (they both return
true), but still no luck. If $withdraw_reque st is less than (<) the
$withdraw_maxim um--ie 543.20 < 543.21, the script works fine.
Also, if I hard code the values, the script works fine. Somewhere
between pulling the maximum from the database and getting the
$_REQUEST variable things are getting lost in translation.
Thanks for any advice
I know this will be an easy fix--but as of now I'm banging my head
against the wall. I need a fresh perspective from the group to see
what my problem is:
This is a simple accounting application, and the code below is
checking to see if a user's withdraw request is greater than their
available balance:
$withdraw_reque st = $_REQUEST['withdraw_amoun t']; // 543.21
$withdraw_maxim um = $user['available_bala nce']; // 543.21
if($withdraw_re quest $withdraw_maxim um) {
echo "Insufficie nt funds.";
} else {
echo "Processing..." ;
}
In my application, both values are equal (543.21), but
$withdraw_reque st $widthdraw_maxi mum still evaluates to TRUE, and
thus shows "Insufficie nt funds." If the two values are whole numbers,
like "543", then they evaluate the way I expect them to.
I've tried everything I can think of, like
$withdraw_reque st = floatval($_REQU EST['withdraw_amoun t']);
$withdraw_maxim um = floatval($user['available_bala nce']);
as well as doing an "isnumeric" check on both values (they both return
true), but still no luck. If $withdraw_reque st is less than (<) the
$withdraw_maxim um--ie 543.20 < 543.21, the script works fine.
Also, if I hard code the values, the script works fine. Somewhere
between pulling the maximum from the database and getting the
$_REQUEST variable things are getting lost in translation.
Thanks for any advice
Comment