nitrogen Posted March 27, 2009 Share Posted March 27, 2009 I'm trying to convert the quadratic formula to a PHP script just to test out PHP's math handling. I'm rather new to math in PHP Here's what I have so far: <html> <head><title>Quadratic Calculator</title><head> <body> <?php $a = filter_input(INPUT_GET, "a"); $b = filter_input(INPUT_GET, "b"); $c = filter_input(INPUT_GET, "c"); $negb = -$b $bsquare = $b * $b $negb = $b * -1 $foura = $a * 4 $fourac = $foura * $c $twoa = $a * 2 $numeratorend = $bsquare - $fourac $numerator1 =$negb + $numeratorend $numerator2 =$negb - $numeratorend $solution1 = $numerator1 / $twoa $solution2 = $numerator2 / $twoa ?> <?php print "<p><center> The solution(s) is/are:<br> $solution1<br> $solution2 </center></p>" ?> <?php print "<br><br> <p> Variable information: <br>a = $a <br>b = $b <br>c = $c <br>bsquare = $bsquare <br>negb = $negb <br>foura = $foura <br>fourac = $fourac <br>twoa = $twoa <br>numeratorend = $numeratorend <br>numerator1 = $numerator1 <br>numerator2 = $numerator2 <br>solution1 = $solution1 <br>solution2 = $solution2 " ?> </body> </html> It obtains variables a, b, and c from an HTML form. When I try to run it I get this error: Parse error: syntax error, unexpected T_VARIABLE in /Applications/xampp/xamppfiles/htdocs/math/quadratic/calculate.php on line 10 Help? Link to comment https://forums.phpfreaks.com/topic/151366-solved-php-math-help-trying-to-make-a-quadratic-calculator/ Share on other sites More sharing options...
nitrogen Posted March 27, 2009 Author Share Posted March 27, 2009 Figured it out! @mikeharris100 @kezabelle and @lewiszheng on Twitter helped me out! I missed ALL my semicolons. Works now! Link to comment https://forums.phpfreaks.com/topic/151366-solved-php-math-help-trying-to-make-a-quadratic-calculator/#findComment-795020 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.