Wolfram Alpha says will give the correct result for the following formula:
((0.0004954*($current^2))-((0.935*$current)+378.486))-
((0.0004954*($desired^2))-((0.935*$desired)+378.486));
But when I run it in PHP, it does not give the correct answer, why not?
$current = mysql_escape_string($_POST['current']);
$desired = mysql_escape_string($_POST['desired']);
$username = mysql_escape_string($_POST['username']);
$password = mysql_escape_string($_POST['password']);
$email = mysql_escape_string($_POST['email']);
$ip = $_SERVER["REMOTE_ADDR"];
$time = time();
$elo = $desired - $current;
if($current < 1200) {
$price = ($elo/100)*30;
} elseif($current < 1400) {
$price = ($elo/100)*35;
} elseif($current < 1901) {
$price = ((0.0004954*($current^2))-((0.935*$current)+378.486))-((0.0004954*($desired^2))-((0.935*$desired)+378.486));
}
The ^
operator is a bitwise operator.
You need to use pow.
If you just want to square a value, then you can just multiple it by itself, $current * $current
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With