lotrfan Posted October 13, 2007 Share Posted October 13, 2007 This is very confusing to me. Many things in programming are , but I know that this is something really dumb that I will kick myself for later. This script parses fine, but the 'if' statement (which, with the given values, is the only part of the code that should execute) starting after my comment, ("//Why does the number of...etc") does not function correctly, even though everything parses correctly... Help! I've made a dumb mistake and I don't know why! //User inputs // //$side_a = 10 //$side_c = 24 and //$angle_a = 150 (degrees) // $side_a = $_REQUEST[side_a]; $side_b = $_REQUEST[side_b]; $side_c = $_REQUEST[side_c]; $angle_a = $_REQUEST[angle_a]; $angle_b = $_REQUEST[angle_b]; $angle_c = $_REQUEST[angle_c]; $side[0]=$side_a; $side[1]=$side_b; $side[2]=$side_c; $angle[0]=$angle_a; $angle[1]=$angle_b; $angle[2]=$angle_c; $angle[0] = deg2rad($angle[0]); $angle[1] = deg2rad($angle[1]); $angle[2] = deg2rad($angle[2]); SSA($side, $angle); function SSA($side, $angle) { $pi = define_pi(); if (empty($side[0])) { if (empty($angle[1])) { if ($angle[2] > ($pi/2)) { if ($side[2] <= $side[1]) //working! { echo "<BR>No solution because 'side c is less than or equal to side b'.<BR>"; } elseif ($side[2] > $side[1]) //working! { $angle[1] = asin(($side[1]*sin($angle[2]))/$side[2]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = ($side[2]*sin($angle[0])/sin($angle[2])); show_me_the_money($side, $angle); } } elseif ($angle[2] < ($pi/2)) { $height = $side[1]*sin($angle[2]); if ($side[2] < $height) //working! { echo "<BR>No solution, the swinging side (c) is shorter than the height.<BR>"; } elseif ($side[2] > $height && $side[2] < $side[1]) //working! { echo "<BR><i>Two solutions, h < c < b. </i><BR>"; $angle[1] = asin(($side[1]*sin($angle[2]))/$side[2]); $angle[0] = $pi - $angle[2] - $angle[1]; $angle_b2 = $pi - $angle[1]; $angle_a2 = $pi - $angle[2] - $angle_b2; $side_a2 = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle_a2))); $side[0] = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle[0]))); $angle_a2 = rad2deg($angle_a2); $angle_b2 = rad2deg($angle_b2); echo "<BR>Angle A<sub>2</sub> = " ,$angle_a2, " degrees <BR>"; echo "Angle B<sub>2</sub> = " ,$angle_b2, " degrees <BR>"; echo "Side a<sub>2</sub> = " ,$side_a2, " units <BR>"; show_me_the_money($side, $angle); } elseif ($side[2] > $height && $side[2] >= $side[1]) //working! { echo "<BR>One solution, c > h and c > b.<BR>"; $angle[1] = asin(($side[1]*sin($angle[2]))/$side[2]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = sqrt(($side[1]*$side[1] + $side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle[0]))); show_me_the_money($side, $angle); } elseif ($side[2] == $height) { echo "<BR>One solution, c = height.<BR>"; $angle[1] = ($pi/2); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = $side[2]*tan($angle[0]); show_me_the_money($side, $angle); } } elseif ($angle[2] == ($pi/2)) //working! { echo "<BR>One solution, Angle B is 90 degrees.<BR>"; $angle[1] = asin($side[1]/$side[2]); $angle[0] = $pi - $angle[2] - $angle[1]; $side[0] = sqrt(($side[2]*$side[2]) - ($side[1]*$side[1])); show_me_the_money($side, $angle); } } elseif (empty($angle[2])) { if ($angle[1] > ($pi/2)) { if ($side[1] <= $side[2]) //working! { echo "<BR>No solution because 'side b is less than or equal to side c'.<BR>"; } elseif ($side[1] > $side[2]) //working! { echo "<BR>One Solution, b > c.<BR>"; $angle[2] = asin(($side[2]*sin($angle[1]))/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = ($side[1]*sin($angle[0]))/sin($angle[1]); show_me_the_money($side, $angle); } } elseif ($angle[1] < ($pi/2)) { $height = $side[2]*sin($angle[1]); if ($side[1] < $height) //working! { echo "<BR>No solution, the swinging side (b) is shorter than the height.<BR>"; } elseif ($side[1] > $height && $side[1] < $side[2]) //working! { echo "<BR>Two solutions, h < b < c."; $angle[2] = asin(($side[2]*sin($angle[1]))/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $angle_c2 = $pi - $angle[2]; $angle_a2 = $pi - $angle[1] - $angle_c2; $side_a2 = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle_a2))); $side[0] = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle[0]))); $angle_c2 = rad2deg($angle_c2); $angle_a2 = rad2deg($angle_a2); echo "<BR>Angle C<sub>2</sub> = " ,$angle_c2, " degrees <BR>"; echo "Angle A<sub>2</sub> = " ,$angle_a2, " degrees <BR>"; echo "Side a<sub>2</sub> = " ,$side_a2, " units <BR>"; show_me_the_money($side, $angle); } elseif ($side[1] > $height && $side[1] >= $side[2]) //working! { echo "<BR>One solution, b > h and b > c.<BR>"; $angle[2] = asin(($side[2]*sin($angle[1]))/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle[0]))); show_me_the_money($side, $angle); } elseif ($side[1] == $height) { echo "<BR>One solution, b = height.<BR>"; $angle[2] = ($pi/2); $angle[0] = $pi - $angle[2] - $angle[1]; $side[0] = sqrt(($side[2]*$side[2]) - ($side[1]*$side[1])); show_me_the_money($side, $angle); } } elseif ($angle[1] == ($pi/2)) //working! { echo "<BR>One Solution, Angle B is 90 degrees.<BR>"; $angle[2] = acos($side[2]/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = sqrt(($side[1]*$side[1]) - ($side[2]*$side[2])); show_me_the_money($side, $angle); } } } elseif (empty($side[1])) { if (empty($angle[0])) { if ($angle[2] > ($pi/2)) { if ($side[2] <= $side[0]) //working! { echo "<BR>No solution because 'side a is less than or equal to side c'.<BR>"; } elseif ($side[2] > $side[0]) //working! { $angle[0] = asin(($side[0]*sin($angle[2]))/$side[2]); $angle[1] = $pi - $angle[0] - $angle[2]; $side[1] = sqrt(($side[0]*$side[0]) +($side[2]*$side[2]) - (2*$side[0]*$side[2]*cos($angle[1]))); show_me_the_money($side, $angle); } } elseif ($angle[2] < ($pi/2)) { $height = $side[0]*sin($angle[2]); if ($side[2] < $height) //working! { echo "<BR>No solution, the swinging side (c) is shorter than the height.<BR>"; } elseif ($side[2] > $height && $side[2] < $side[0]) //working! { echo "<BR>Two solutions, h < c < a.<BR>"; $angle[0] = asin(($side[0]*sin($angle[2]))/$side[2]); $angle[1] = $pi - $angle[0] - $angle[2]; $angle_a2 = $pi - $angle[0]; $angle_b2 = $pi - $angle[2] - $angle_a2; $side_b2 = sqrt((($side[0]*$side[0]) + ($side[2]*$side[2]))-(2*$side[0]*$side[2]*cos($angle_b2))); $side[1] = sqrt((($side[0]*$side[0]) + ($side[2]*$side[2]))-(2*$side[0]*$side[2]*cos($angle[1]))); $angle_a2 = rad2deg($angle_a2); $angle_b2 = rad2deg($angle_b2); echo "<BR>Angle A<sub>2</sub> = " ,$angle_a2, " degrees <BR>"; echo "Angle B<sub>2</sub> = " ,$angle_b2, " degrees <BR>"; echo "Side b<sub>2</sub> = " ,$side_b2, " units <BR>"; show_me_the_money($side, $angle); } elseif ($side[2] > $height && $side[2] >= $side[0]) //working! { echo "<BR>One solution, c > h and c > a.<BR>"; $angle[0] = asin(($side[0]*sin($angle[2]))/$side[2]); $angle[1] = $pi - $angle[0] - $angle[2]; $side[1] = sqrt((($side[0]*$side[0]) + ($side[2]*$side[2]))-(2*$side[0]*$side[2]*cos($angle[1]))); show_me_the_money($side, $angle); } elseif ($side[2] == $height) { echo "<BR>One solution, c = height.<BR>"; $angle[0] = ($pi/2); $angle[1] = $pi - $angle[0] - $angle[2]; $side[1] = $side[2]*tan($angle[1]); show_me_the_money($side, $angle); } } elseif ($angle[2] == ($pi/2)) //working! { echo "<BR>One solution, Angle C is 90 degrees.<BR>"; $side[1] = sqrt(($side[2]*$side[2]) - ($side[0]*$side[0])); $angle[0] = asin($side[0]*sin($angle[2])/$side[2]); $angle[1] = $pi - $angle[0] - $angle[2]; show_me_the_money($side, $angle); } } } //Side note: when I remove this line (just the '}') I get an "$end" error /// Why does the number of curly brackets not match up correctly -- yet still parses!!! //Line below is part that should be functioning, but isn't... elseif (empty($angle[2])) { if ($angle[0] > ($pi/2)) { if ($side[0] <= $side[2]) { echo "<BR>No solution because 'side is less than or equal to side '.<BR>"; } elseif ($side[1] > $side[2]) { echo "<BR>One Solution, b > c.<BR>"; $angle[2] = asin(($side[2]*sin($angle[1]))/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = ($side[0]*sin($angle[2]))/sin($angle[2]); show_me_the_money($side, $angle); } } elseif ($angle[1] < ($pi/2)) { $height = $side[2]*sin($angle[1]); if ($side[1] < $height) { echo "<BR>No solution, the swinging side (b) is shorter than the height.<BR>"; } elseif ($side[1] > $height && $side[1] < $side[2]) { echo "<BR>Two solutions, h < b < c.<BR>"; $angle[2] = asin(($side[2]*sin($angle[1]))/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $angle_c2 = $pi - $angle[2]; $angle_a2 = $pi - $angle[1] - $angle_c2; $side_a2 = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle_a2))); $side[0] = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[1]*cos($angle[0]))); $angle_c2 = rad2deg($angle_c2); $angle_a2 = rad2deg($angle_a2); echo "<BR>Angle C<sub>2</sub> = " ,$angle_c2, " degrees <BR>"; echo "Angle A<sub>2</sub> = " ,$angle_a2, " degrees <BR>"; echo "Side a<sub>2</sub> = " ,$side_a2, " units <BR>"; show_me_the_money($side, $angle); } elseif ($side[1] > $height && $side[1] >= $side[2]) { echo "<BR>One solution, b > h and b > c.<BR>"; $angle[2] = asin(($side[2]*sin($angle[1]))/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle[0]))); show_me_the_money($side, $angle); } elseif ($side[1] == $height) { echo "<BR>One solution, b = height.<BR>"; $angle[2] = ($pi/2); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = sqrt(($side[2]*$side[2]) - ($side[1]*$side[1])); show_me_the_money($side, $angle); } } elseif ($angle[1] == ($pi/2)) { echo "<BR>One Solution, Angle B is 90 degrees.<BR>"; $angle[2] = asin($side[2]/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = sqrt(($side[1]*$side[1]) - ($side[2]*$side[2])); show_me_the_money($side, $angle); } } elseif (empty($side[2])) { if (empty($angle[0])) { if ($angle[1] > ($pi/2)) { if ($side[1] <= $side[0]) { echo "<BR>No solution because 'side b is less than or equal to side a'.<BR>"; } elseif ($side[1] > $side[0]) { $angle[0] = asin(($side[0]*sin($angle[1]))/$side[1]); $angle[2] = $pi - $angle[0] - $angle[1]; $side[2] = ($side[1]*sin($angle[2]))/sin($angle[1]); show_me_the_money($side, $angle); } } elseif ($angle[1] < ($pi/2)) { $height = $side[0]*sin($angle[1]); if ($side[1] < $height) { echo "<BR>No solution, the swinging side (b) is shorter than the height.<BR>"; } elseif ($side[1] > $height && $side[1] < $side[0]) { echo "<BR>Two solutions, h < b < a ."; $angle[0] = asin(($side[0]*sin($angle[1]))/$side[1]); $angle[2] = $pi - $angle[1] - $angle[0]; $angle_a2 = $pi - $angle[0]; $angle_c2 = $pi - $angle[1] - $angle_a2; $side_c2 = sqrt((($side[0]*$side[0]) + ($side[1]*$side[1]))-(2*$side[0]*$side[1]*cos($angle_c2))); $side[2] = sqrt(($side[1]*$side[1]) + ($side[0]*$side[0])-(2*$side[1]*$side[0]*cos($angle[2]))); $angle_c2 = rad2deg($angle_c2); $angle_a2 = rad2deg($angle_a2); echo "<BR>Angle C<sub>2</sub> = " ,$angle_c2, " degrees <BR>"; echo "Angle A<sub>2</sub> = " ,$angle_a2, " degrees <BR>"; echo "Side c<sub>2</sub> = " ,$side_c2, " units <BR>"; show_me_the_money($side, $angle); } elseif ($side[1] > $height && $side[1] >= $side[0]) { echo "<BR>One solution, b > h and b > a.<BR>"; $angle[0] = asin(($side[0]*sin($angle[1]))/$side[1]); $angle[2] = $pi - $angle[1] - $angle[0]; $side[2] = sqrt((($side[1]*$side[1]) + ($side[0]*$side[0]))-(2*$side[1]*$side[0]*cos($angle[2]))); show_me_the_money($side, $angle); } elseif ($side[1] == $height) { echo "<BR>One solution, b = height.<BR>"; $angle[0] = ($pi/2); $angle[2] = $pi - $angle[1] - $angle[0]; $side[2] = sqrt(($side[0]*$side[0]) - ($side[1]*$side[1])); show_me_the_money($side, $angle); } } elseif ($angle[1] == ($pi/2)) { echo "<BR>One solution, Angle B is 90 degrees.<BR>"; $side[2] = sqrt(($side[1]*$side[1]) - ($side[0]*$side[0])); $angle[0] = asin($side[0]*sin($angle[1])/$side[1]); $angle[2] = $pi - $angle[1] - $angle[0]; show_me_the_money($side, $angle); } } } elseif (empty($angle[1])) { if ($angle[0] > ($pi/2)) { if ($side[0] <= $side[1]) { echo "<BR>No solution because 'side a is less than or equal to side b'.<BR>"; } elseif ($side[0] > $side[1]) { echo "<BR>One Solution, a > b.<BR>"; $angle[1] = asin(($side[1]*sin($angle[0]))/$side[0]); $angle[2] = $pi - $angle[1] - $angle[0]; $side[2] = ($side[0]*sin($angle[2]))/sin($angle[0]); show_me_the_money($side, $angle); } } elseif ($angle[0] < ($pi/2)) { $height = $side[1]*sin($angle[0]); if ($side[0] < $height) { echo "<BR>No solution, the swinging side (a) is shorter than the height.<BR>"; } elseif ($side[0] > $height && $side[0] < $side[1]) { echo "<BR>Two solutions, h < a < c."; $angle[1] = asin(($side[1]*sin($angle[0]))/$side[0]); $angle[2] = $pi - $angle[0] - $angle[1]; $angle_b2 = $pi - $angle[1]; $angle_c2 = $pi - $angle[0] - $angle_b2; $side_c2 = sqrt(($side[1]*$side[1]) + ($side[0]*$side[0])-(2*$side[1]*$side[0]*cos($angle_c2))); $side[2] = sqrt(($side[1]*$side[1]) + ($side[0]*$side[0])-(2*$side[0]*$side[1]*cos($angle[2]))); $angle_b2 = rad2deg($angle_c2); $angle_c2 = rad2deg($angle_a2); echo "<BR>Angle B<sub>2</sub> = " ,$angle_b2, " degrees <BR>"; echo "Angle C<sub>2</sub> = " ,$angle_c2, " degrees <BR>"; echo "Side c<sub>2</sub> = " ,$side_c2, " units <BR>"; show_me_the_money($side, $angle); } elseif ($side[0] > $height && $side[0] >= $side[1]) { echo "<BR>One solution, a > h and a > b.<BR>"; $angle[1] = asin(($side[1]*sin($angle[0]))/$side[0]); $angle[2] = $pi - $angle[0] - $angle[1]; $side[2] = sqrt(($side[1]*$side[1]) + ($side[0]*$side[0])-(2*$side[0]*$side[1]*cos($angle[2]))); show_me_the_money($side, $angle); } elseif ($side[0] == $height) { echo "<BR>One solution, a = height.<BR>"; $angle[1] = ($pi/2); $angle[2] = $pi - $angle[1] - $angle[0]; $side[2] = sqrt(($side[1]*$side[1]) - ($side[0]*$side[0])); show_me_the_money($side, $angle); } } elseif ($angle[0] == ($pi/2)) { echo "<BR>One Solution, Angle A is 90 degrees.<BR>"; $angle[1] = asin($side[1]/$side[0]); $angle[2] = $pi - $angle[0] - $angle[1]; $side[2] = sqrt(($side[0]*$side[0]) - ($side[1]*$side[1])); show_me_the_money($side, $angle); } } } function define_pi() { $pi = 3.14159265358979323846; return $pi; } I know this code is MASSIVE, so don't feel obligated to do my proofreading for me . I may electronically hug anyone who can at least lead me in the right direction, though...I spent 9 hours today trying to fix... Thanks in Advance! Quote Link to comment https://forums.phpfreaks.com/topic/73135-solved-help-ive-made-a-dumb-mistake-but-i-dont-know-how/ Share on other sites More sharing options...
MadTechie Posted October 13, 2007 Share Posted October 13, 2007 try this (re-tabbed) <?php //User inputs // //$side_a = 10 //$side_c = 24 and //$angle_a = 150 (degrees) // $side_a = $_REQUEST[side_a]; $side_b = $_REQUEST[side_b]; $side_c = $_REQUEST[side_c]; $angle_a = $_REQUEST[angle_a]; $angle_b = $_REQUEST[angle_b]; $angle_c = $_REQUEST[angle_c]; $side[0]=$side_a; $side[1]=$side_b; $side[2]=$side_c; $angle[0]=$angle_a; $angle[1]=$angle_b; $angle[2]=$angle_c; $angle[0] = deg2rad($angle[0]); $angle[1] = deg2rad($angle[1]); $angle[2] = deg2rad($angle[2]); SSA($side, $angle); function SSA($side, $angle) { $pi = define_pi(); if (empty($side[0])) { if (empty($angle[1])) { if ($angle[2] > ($pi/2)) { if ($side[2] <= $side[1]) //working! { echo "<BR>No solution because 'side c is less than or equal to side b'.<BR>"; } elseif ($side[2] > $side[1]) //working! { $angle[1] = asin(($side[1]*sin($angle[2]))/$side[2]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = ($side[2]*sin($angle[0])/sin($angle[2])); show_me_the_money($side, $angle); } } elseif ($angle[2] < ($pi/2)) { $height = $side[1]*sin($angle[2]); if ($side[2] < $height) //working! { echo "<BR>No solution, the swinging side (c) is shorter than the height.<BR>"; } elseif ($side[2] > $height && $side[2] < $side[1]) //working! { echo "<BR><i>Two solutions, h < c < b. </i><BR>"; $angle[1] = asin(($side[1]*sin($angle[2]))/$side[2]); $angle[0] = $pi - $angle[2] - $angle[1]; $angle_b2 = $pi - $angle[1]; $angle_a2 = $pi - $angle[2] - $angle_b2; $side_a2 = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle_a2))); $side[0] = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle[0]))); $angle_a2 = rad2deg($angle_a2); $angle_b2 = rad2deg($angle_b2); echo "<BR>Angle A<sub>2</sub> = " ,$angle_a2, " degrees <BR>"; echo "Angle B<sub>2</sub> = " ,$angle_b2, " degrees <BR>"; echo "Side a<sub>2</sub> = " ,$side_a2, " units <BR>"; show_me_the_money($side, $angle); } elseif ($side[2] > $height && $side[2] >= $side[1]) //working! { echo "<BR>One solution, c > h and c > b.<BR>"; $angle[1] = asin(($side[1]*sin($angle[2]))/$side[2]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = sqrt(($side[1]*$side[1] + $side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle[0]))); show_me_the_money($side, $angle); } elseif ($side[2] == $height) { echo "<BR>One solution, c = height.<BR>"; $angle[1] = ($pi/2); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = $side[2]*tan($angle[0]); show_me_the_money($side, $angle); } } elseif ($angle[2] == ($pi/2)) //working! { echo "<BR>One solution, Angle B is 90 degrees.<BR>"; $angle[1] = asin($side[1]/$side[2]); $angle[0] = $pi - $angle[2] - $angle[1]; $side[0] = sqrt(($side[2]*$side[2]) - ($side[1]*$side[1])); show_me_the_money($side, $angle); } } elseif (empty($angle[2])) { if ($angle[1] > ($pi/2)) { if ($side[1] <= $side[2]) //working! { echo "<BR>No solution because 'side b is less than or equal to side c'.<BR>"; } elseif ($side[1] > $side[2]) //working! { echo "<BR>One Solution, b > c.<BR>"; $angle[2] = asin(($side[2]*sin($angle[1]))/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = ($side[1]*sin($angle[0]))/sin($angle[1]); show_me_the_money($side, $angle); } } elseif ($angle[1] < ($pi/2)) { $height = $side[2]*sin($angle[1]); if ($side[1] < $height) //working! { echo "<BR>No solution, the swinging side (b) is shorter than the height.<BR>"; } elseif ($side[1] > $height && $side[1] < $side[2]) //working! { echo "<BR>Two solutions, h < b < c."; $angle[2] = asin(($side[2]*sin($angle[1]))/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $angle_c2 = $pi - $angle[2]; $angle_a2 = $pi - $angle[1] - $angle_c2; $side_a2 = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle_a2))); $side[0] = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle[0]))); $angle_c2 = rad2deg($angle_c2); $angle_a2 = rad2deg($angle_a2); echo "<BR>Angle C<sub>2</sub> = " ,$angle_c2, " degrees <BR>"; echo "Angle A<sub>2</sub> = " ,$angle_a2, " degrees <BR>"; echo "Side a<sub>2</sub> = " ,$side_a2, " units <BR>"; show_me_the_money($side, $angle); } elseif ($side[1] > $height && $side[1] >= $side[2]) //working! { echo "<BR>One solution, b > h and b > c.<BR>"; $angle[2] = asin(($side[2]*sin($angle[1]))/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle[0]))); show_me_the_money($side, $angle); } elseif ($side[1] == $height) { echo "<BR>One solution, b = height.<BR>"; $angle[2] = ($pi/2); $angle[0] = $pi - $angle[2] - $angle[1]; $side[0] = sqrt(($side[2]*$side[2]) - ($side[1]*$side[1])); show_me_the_money($side, $angle); } } elseif ($angle[1] == ($pi/2)) //working! { echo "<BR>One Solution, Angle B is 90 degrees.<BR>"; $angle[2] = acos($side[2]/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = sqrt(($side[1]*$side[1]) - ($side[2]*$side[2])); show_me_the_money($side, $angle); } } } elseif (empty($side[1])) { if (empty($angle[0])) { if ($angle[2] > ($pi/2)) { if ($side[2] <= $side[0]) //working! { echo "<BR>No solution because 'side a is less than or equal to side c'.<BR>"; } elseif ($side[2] > $side[0]) //working! { $angle[0] = asin(($side[0]*sin($angle[2]))/$side[2]); $angle[1] = $pi - $angle[0] - $angle[2]; $side[1] = sqrt(($side[0]*$side[0]) +($side[2]*$side[2]) - (2*$side[0]*$side[2]*cos($angle[1]))); show_me_the_money($side, $angle); } } elseif ($angle[2] < ($pi/2)) { $height = $side[0]*sin($angle[2]); if ($side[2] < $height) //working! { echo "<BR>No solution, the swinging side (c) is shorter than the height.<BR>"; } elseif ($side[2] > $height && $side[2] < $side[0]) //working! { echo "<BR>Two solutions, h < c < a.<BR>"; $angle[0] = asin(($side[0]*sin($angle[2]))/$side[2]); $angle[1] = $pi - $angle[0] - $angle[2]; $angle_a2 = $pi - $angle[0]; $angle_b2 = $pi - $angle[2] - $angle_a2; $side_b2 = sqrt((($side[0]*$side[0]) + ($side[2]*$side[2]))-(2*$side[0]*$side[2]*cos($angle_b2))); $side[1] = sqrt((($side[0]*$side[0]) + ($side[2]*$side[2]))-(2*$side[0]*$side[2]*cos($angle[1]))); $angle_a2 = rad2deg($angle_a2); $angle_b2 = rad2deg($angle_b2); echo "<BR>Angle A<sub>2</sub> = " ,$angle_a2, " degrees <BR>"; echo "Angle B<sub>2</sub> = " ,$angle_b2, " degrees <BR>"; echo "Side b<sub>2</sub> = " ,$side_b2, " units <BR>"; show_me_the_money($side, $angle); } elseif ($side[2] > $height && $side[2] >= $side[0]) //working! { echo "<BR>One solution, c > h and c > a.<BR>"; $angle[0] = asin(($side[0]*sin($angle[2]))/$side[2]); $angle[1] = $pi - $angle[0] - $angle[2]; $side[1] = sqrt((($side[0]*$side[0]) + ($side[2]*$side[2]))-(2*$side[0]*$side[2]*cos($angle[1]))); show_me_the_money($side, $angle); } elseif ($side[2] == $height) { echo "<BR>One solution, c = height.<BR>"; $angle[0] = ($pi/2); $angle[1] = $pi - $angle[0] - $angle[2]; $side[1] = $side[2]*tan($angle[1]); show_me_the_money($side, $angle); } } elseif ($angle[2] == ($pi/2)) //working! { echo "<BR>One solution, Angle C is 90 degrees.<BR>"; $side[1] = sqrt(($side[2]*$side[2]) - ($side[0]*$side[0])); $angle[0] = asin($side[0]*sin($angle[2])/$side[2]); $angle[1] = $pi - $angle[0] - $angle[2]; show_me_the_money($side, $angle); } } } //Side note: when I remove this line (just the '}') I get an "$end" error /// Why does the number of curly brackets not match up correctly -- yet still parses!!! //Line below is part that should be functioning, but isn't... elseif (empty($angle[2])) { if ($angle[0] > ($pi/2)) { if ($side[0] <= $side[2]) { echo "<BR>No solution because 'side is less than or equal to side '.<BR>"; } elseif ($side[1] > $side[2]) { echo "<BR>One Solution, b > c.<BR>"; $angle[2] = asin(($side[2]*sin($angle[1]))/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = ($side[0]*sin($angle[2]))/sin($angle[2]); show_me_the_money($side, $angle); } } elseif ($angle[1] < ($pi/2)) { $height = $side[2]*sin($angle[1]); if ($side[1] < $height) { echo "<BR>No solution, the swinging side (b) is shorter than the height.<BR>"; } elseif ($side[1] > $height && $side[1] < $side[2]) { echo "<BR>Two solutions, h < b < c.<BR>"; $angle[2] = asin(($side[2]*sin($angle[1]))/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $angle_c2 = $pi - $angle[2]; $angle_a2 = $pi - $angle[1] - $angle_c2; $side_a2 = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle_a2))); $side[0] = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[1]*cos($angle[0]))); $angle_c2 = rad2deg($angle_c2); $angle_a2 = rad2deg($angle_a2); echo "<BR>Angle C<sub>2</sub> = " ,$angle_c2, " degrees <BR>"; echo "Angle A<sub>2</sub> = " ,$angle_a2, " degrees <BR>"; echo "Side a<sub>2</sub> = " ,$side_a2, " units <BR>"; show_me_the_money($side, $angle); } elseif ($side[1] > $height && $side[1] >= $side[2]) { echo "<BR>One solution, b > h and b > c.<BR>"; $angle[2] = asin(($side[2]*sin($angle[1]))/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle[0]))); show_me_the_money($side, $angle); } elseif ($side[1] == $height) { echo "<BR>One solution, b = height.<BR>"; $angle[2] = ($pi/2); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = sqrt(($side[2]*$side[2]) - ($side[1]*$side[1])); show_me_the_money($side, $angle); } } elseif ($angle[1] == ($pi/2)) { echo "<BR>One Solution, Angle B is 90 degrees.<BR>"; $angle[2] = asin($side[2]/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = sqrt(($side[1]*$side[1]) - ($side[2]*$side[2])); show_me_the_money($side, $angle); } } elseif (empty($side[2])) { if (empty($angle[0])) { if ($angle[1] > ($pi/2)) { if ($side[1] <= $side[0]) { echo "<BR>No solution because 'side b is less than or equal to side a'.<BR>"; } elseif ($side[1] > $side[0]) { $angle[0] = asin(($side[0]*sin($angle[1]))/$side[1]); $angle[2] = $pi - $angle[0] - $angle[1]; $side[2] = ($side[1]*sin($angle[2]))/sin($angle[1]); show_me_the_money($side, $angle); } } elseif ($angle[1] < ($pi/2)) { $height = $side[0]*sin($angle[1]); if ($side[1] < $height) { echo "<BR>No solution, the swinging side (b) is shorter than the height.<BR>"; } elseif ($side[1] > $height && $side[1] < $side[0]) { echo "<BR>Two solutions, h < b < a ."; $angle[0] = asin(($side[0]*sin($angle[1]))/$side[1]); $angle[2] = $pi - $angle[1] - $angle[0]; $angle_a2 = $pi - $angle[0]; $angle_c2 = $pi - $angle[1] - $angle_a2; $side_c2 = sqrt((($side[0]*$side[0]) + ($side[1]*$side[1]))-(2*$side[0]*$side[1]*cos($angle_c2))); $side[2] = sqrt(($side[1]*$side[1]) + ($side[0]*$side[0])-(2*$side[1]*$side[0]*cos($angle[2]))); $angle_c2 = rad2deg($angle_c2); $angle_a2 = rad2deg($angle_a2); echo "<BR>Angle C<sub>2</sub> = " ,$angle_c2, " degrees <BR>"; echo "Angle A<sub>2</sub> = " ,$angle_a2, " degrees <BR>"; echo "Side c<sub>2</sub> = " ,$side_c2, " units <BR>"; show_me_the_money($side, $angle); } elseif ($side[1] > $height && $side[1] >= $side[0]) { echo "<BR>One solution, b > h and b > a.<BR>"; $angle[0] = asin(($side[0]*sin($angle[1]))/$side[1]); $angle[2] = $pi - $angle[1] - $angle[0]; $side[2] = sqrt((($side[1]*$side[1]) + ($side[0]*$side[0]))-(2*$side[1]*$side[0]*cos($angle[2]))); show_me_the_money($side, $angle); } elseif ($side[1] == $height) { echo "<BR>One solution, b = height.<BR>"; $angle[0] = ($pi/2); $angle[2] = $pi - $angle[1] - $angle[0]; $side[2] = sqrt(($side[0]*$side[0]) - ($side[1]*$side[1])); show_me_the_money($side, $angle); } } elseif ($angle[1] == ($pi/2)) { echo "<BR>One solution, Angle B is 90 degrees.<BR>"; $side[2] = sqrt(($side[1]*$side[1]) - ($side[0]*$side[0])); $angle[0] = asin($side[0]*sin($angle[1])/$side[1]); $angle[2] = $pi - $angle[1] - $angle[0]; show_me_the_money($side, $angle); } } } elseif (empty($angle[1])) { if ($angle[0] > ($pi/2)) { if ($side[0] <= $side[1]) { echo "<BR>No solution because 'side a is less than or equal to side b'.<BR>"; } elseif ($side[0] > $side[1]) { echo "<BR>One Solution, a > b.<BR>"; $angle[1] = asin(($side[1]*sin($angle[0]))/$side[0]); $angle[2] = $pi - $angle[1] - $angle[0]; $side[2] = ($side[0]*sin($angle[2]))/sin($angle[0]); show_me_the_money($side, $angle); } } elseif ($angle[0] < ($pi/2)) { $height = $side[1]*sin($angle[0]); if ($side[0] < $height) { echo "<BR>No solution, the swinging side (a) is shorter than the height.<BR>"; } elseif ($side[0] > $height && $side[0] < $side[1]) { echo "<BR>Two solutions, h < a < c."; $angle[1] = asin(($side[1]*sin($angle[0]))/$side[0]); $angle[2] = $pi - $angle[0] - $angle[1]; $angle_b2 = $pi - $angle[1]; $angle_c2 = $pi - $angle[0] - $angle_b2; $side_c2 = sqrt(($side[1]*$side[1]) + ($side[0]*$side[0])-(2*$side[1]*$side[0]*cos($angle_c2))); $side[2] = sqrt(($side[1]*$side[1]) + ($side[0]*$side[0])-(2*$side[0]*$side[1]*cos($angle[2]))); $angle_b2 = rad2deg($angle_c2); $angle_c2 = rad2deg($angle_a2); echo "<BR>Angle B<sub>2</sub> = " ,$angle_b2, " degrees <BR>"; echo "Angle C<sub>2</sub> = " ,$angle_c2, " degrees <BR>"; echo "Side c<sub>2</sub> = " ,$side_c2, " units <BR>"; show_me_the_money($side, $angle); } elseif ($side[0] > $height && $side[0] >= $side[1]) { echo "<BR>One solution, a > h and a > b.<BR>"; $angle[1] = asin(($side[1]*sin($angle[0]))/$side[0]); $angle[2] = $pi - $angle[0] - $angle[1]; $side[2] = sqrt(($side[1]*$side[1]) + ($side[0]*$side[0])-(2*$side[0]*$side[1]*cos($angle[2]))); show_me_the_money($side, $angle); } elseif ($side[0] == $height) { echo "<BR>One solution, a = height.<BR>"; $angle[1] = ($pi/2); $angle[2] = $pi - $angle[1] - $angle[0]; $side[2] = sqrt(($side[1]*$side[1]) - ($side[0]*$side[0])); show_me_the_money($side, $angle); } } elseif ($angle[0] == ($pi/2)) { echo "<BR>One Solution, Angle A is 90 degrees.<BR>"; $angle[1] = asin($side[1]/$side[0]); $angle[2] = $pi - $angle[0] - $angle[1]; $side[2] = sqrt(($side[0]*$side[0]) - ($side[1]*$side[1])); show_me_the_money($side, $angle); } } } function define_pi() { $pi = 3.14159265358979323846; return $pi; } #debug #function show_me_the_money() #{} ?> Quote Link to comment https://forums.phpfreaks.com/topic/73135-solved-help-ive-made-a-dumb-mistake-but-i-dont-know-how/#findComment-368831 Share on other sites More sharing options...
MadTechie Posted October 14, 2007 Share Posted October 14, 2007 as a note: if your using a find to count the { compared to } please remember that you have a } commented out Quote Link to comment https://forums.phpfreaks.com/topic/73135-solved-help-ive-made-a-dumb-mistake-but-i-dont-know-how/#findComment-368866 Share on other sites More sharing options...
lotrfan Posted October 14, 2007 Author Share Posted October 14, 2007 No, I was just counting it manually. I tried to see if each { had a }. Did you find an incomplete pair {}? Because unless you fixed a bracket, just tabbing differently wouldn't change the outcome. if the // comment bars are to the right of the code, they don't cancel or comment out the code, do they? You might have to explain what you mean... Thanks for your help, I'm a real newbie at PHP. Quote Link to comment https://forums.phpfreaks.com/topic/73135-solved-help-ive-made-a-dumb-mistake-but-i-dont-know-how/#findComment-369037 Share on other sites More sharing options...
monkeybidz Posted October 14, 2007 Share Posted October 14, 2007 What does: show_me_the_money($side, $angle); represent? No $ Quote Link to comment https://forums.phpfreaks.com/topic/73135-solved-help-ive-made-a-dumb-mistake-but-i-dont-know-how/#findComment-369074 Share on other sites More sharing options...
MadTechie Posted October 14, 2007 Share Posted October 14, 2007 if you do a find for "{" your find your find 65 of them if you do a find for "}" your find your find 66 of them So it would seam that theirs an extra } but you need to take into account this line //Side note: when I remove this line (just the '}') I get an "$end" error so theirs infact 65 of both.. so you probably miss-counted, either that or i fixed the problem without noticing!!, i am refering to my post hope that makes sence.. Quote Link to comment https://forums.phpfreaks.com/topic/73135-solved-help-ive-made-a-dumb-mistake-but-i-dont-know-how/#findComment-369163 Share on other sites More sharing options...
lotrfan Posted October 14, 2007 Author Share Posted October 14, 2007 Thanks for keeping up with my post everybody. @monkeybidz: show_me_the_money($side, $angle); is just a function that I didn't include because all it does is echo my variables (I'm just passing two arrays into the function). ------------------------ Well, when I run the code, the page goes blank whenever I enter values that would be used by the code under my comment ( //Line that should be working...). I don't get a parse error, but it doesn't do anything, either. ??? What kind of situation could be causing that? The rest of the time, the rest of the code functions fine. P.S. How do you "do a find" for {}? Quote Link to comment https://forums.phpfreaks.com/topic/73135-solved-help-ive-made-a-dumb-mistake-but-i-dont-know-how/#findComment-369352 Share on other sites More sharing options...
MadTechie Posted October 14, 2007 Share Posted October 14, 2007 your comment refers to the line below /// Why does the number of curly brackets not match up correctly -- yet still parses!!! //Line below is part that should be functioning, but isn't... elseif (empty($angle[2])) { if ($angle[0] > ($pi/2)) { as a note in my tests that line works fine.. full code.. (your note the die("KILLED") <?php //User inputs // //$side_a = 10 //$side_c = 24 and //$angle_a = 150 (degrees) // $side_a = 10;//$_REQUEST['side_a']; $side_b = 24;//$_REQUEST['side_b']; $side_c = $_REQUEST['side_c']; $angle_a = 150;//$_REQUEST['angle_a']; $angle_b = $_REQUEST['angle_b']; $angle_c = $_REQUEST['angle_c']; $side[0]=$side_a; $side[1]=$side_b; $side[2]=$side_c; $angle[0]=$angle_a; $angle[1]=$angle_b; $angle[2]=$angle_c; $angle[0] = deg2rad($angle[0]); $angle[1] = deg2rad($angle[1]); $angle[2] = deg2rad($angle[2]); SSA($side, $angle); function SSA($side, $angle) { $pi = define_pi(); if (empty($side[0])) { if (empty($angle[1])) { if ($angle[2] > ($pi/2)) { if ($side[2] <= $side[1]) //working! { echo "<BR>No solution because 'side c is less than or equal to side b'.<BR>"; } elseif ($side[2] > $side[1]) //working! { $angle[1] = asin(($side[1]*sin($angle[2]))/$side[2]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = ($side[2]*sin($angle[0])/sin($angle[2])); show_me_the_money($side, $angle); } } elseif ($angle[2] < ($pi/2)) { $height = $side[1]*sin($angle[2]); if ($side[2] < $height) //working! { echo "<BR>No solution, the swinging side (c) is shorter than the height.<BR>"; } elseif ($side[2] > $height && $side[2] < $side[1]) //working! { echo "<BR><i>Two solutions, h < c < b. </i><BR>"; $angle[1] = asin(($side[1]*sin($angle[2]))/$side[2]); $angle[0] = $pi - $angle[2] - $angle[1]; $angle_b2 = $pi - $angle[1]; $angle_a2 = $pi - $angle[2] - $angle_b2; $side_a2 = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle_a2))); $side[0] = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle[0]))); $angle_a2 = rad2deg($angle_a2); $angle_b2 = rad2deg($angle_b2); echo "<BR>Angle A<sub>2</sub> = " ,$angle_a2, " degrees <BR>"; echo "Angle B<sub>2</sub> = " ,$angle_b2, " degrees <BR>"; echo "Side a<sub>2</sub> = " ,$side_a2, " units <BR>"; show_me_the_money($side, $angle); } elseif ($side[2] > $height && $side[2] >= $side[1]) //working! { echo "<BR>One solution, c > h and c > b.<BR>"; $angle[1] = asin(($side[1]*sin($angle[2]))/$side[2]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = sqrt(($side[1]*$side[1] + $side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle[0]))); show_me_the_money($side, $angle); } elseif ($side[2] == $height) { echo "<BR>One solution, c = height.<BR>"; $angle[1] = ($pi/2); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = $side[2]*tan($angle[0]); show_me_the_money($side, $angle); } } elseif ($angle[2] == ($pi/2)) //working! { echo "<BR>One solution, Angle B is 90 degrees.<BR>"; $angle[1] = asin($side[1]/$side[2]); $angle[0] = $pi - $angle[2] - $angle[1]; $side[0] = sqrt(($side[2]*$side[2]) - ($side[1]*$side[1])); show_me_the_money($side, $angle); } } elseif (empty($angle[2])) { if ($angle[1] > ($pi/2)) { if ($side[1] <= $side[2]) //working! { echo "<BR>No solution because 'side b is less than or equal to side c'.<BR>"; } elseif ($side[1] > $side[2]) //working! { echo "<BR>One Solution, b > c.<BR>"; $angle[2] = asin(($side[2]*sin($angle[1]))/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = ($side[1]*sin($angle[0]))/sin($angle[1]); show_me_the_money($side, $angle); } } elseif ($angle[1] < ($pi/2)) { $height = $side[2]*sin($angle[1]); if ($side[1] < $height) //working! { echo "<BR>No solution, the swinging side (b) is shorter than the height.<BR>"; } elseif ($side[1] > $height && $side[1] < $side[2]) //working! { echo "<BR>Two solutions, h < b < c."; $angle[2] = asin(($side[2]*sin($angle[1]))/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $angle_c2 = $pi - $angle[2]; $angle_a2 = $pi - $angle[1] - $angle_c2; $side_a2 = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle_a2))); $side[0] = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle[0]))); $angle_c2 = rad2deg($angle_c2); $angle_a2 = rad2deg($angle_a2); echo "<BR>Angle C<sub>2</sub> = " ,$angle_c2, " degrees <BR>"; echo "Angle A<sub>2</sub> = " ,$angle_a2, " degrees <BR>"; echo "Side a<sub>2</sub> = " ,$side_a2, " units <BR>"; show_me_the_money($side, $angle); } elseif ($side[1] > $height && $side[1] >= $side[2]) //working! { echo "<BR>One solution, b > h and b > c.<BR>"; $angle[2] = asin(($side[2]*sin($angle[1]))/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle[0]))); show_me_the_money($side, $angle); } elseif ($side[1] == $height) { echo "<BR>One solution, b = height.<BR>"; $angle[2] = ($pi/2); $angle[0] = $pi - $angle[2] - $angle[1]; $side[0] = sqrt(($side[2]*$side[2]) - ($side[1]*$side[1])); show_me_the_money($side, $angle); } } elseif ($angle[1] == ($pi/2)) //working! { echo "<BR>One Solution, Angle B is 90 degrees.<BR>"; $angle[2] = acos($side[2]/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = sqrt(($side[1]*$side[1]) - ($side[2]*$side[2])); show_me_the_money($side, $angle); } } } elseif (empty($side[1])) { if (empty($angle[0])) { if ($angle[2] > ($pi/2)) { if ($side[2] <= $side[0]) //working! { echo "<BR>No solution because 'side a is less than or equal to side c'.<BR>"; } elseif ($side[2] > $side[0]) //working! { $angle[0] = asin(($side[0]*sin($angle[2]))/$side[2]); $angle[1] = $pi - $angle[0] - $angle[2]; $side[1] = sqrt(($side[0]*$side[0]) +($side[2]*$side[2]) - (2*$side[0]*$side[2]*cos($angle[1]))); show_me_the_money($side, $angle); } } elseif ($angle[2] < ($pi/2)) { $height = $side[0]*sin($angle[2]); if ($side[2] < $height) //working! { echo "<BR>No solution, the swinging side (c) is shorter than the height.<BR>"; } elseif ($side[2] > $height && $side[2] < $side[0]) //working! { echo "<BR>Two solutions, h < c < a.<BR>"; $angle[0] = asin(($side[0]*sin($angle[2]))/$side[2]); $angle[1] = $pi - $angle[0] - $angle[2]; $angle_a2 = $pi - $angle[0]; $angle_b2 = $pi - $angle[2] - $angle_a2; $side_b2 = sqrt((($side[0]*$side[0]) + ($side[2]*$side[2]))-(2*$side[0]*$side[2]*cos($angle_b2))); $side[1] = sqrt((($side[0]*$side[0]) + ($side[2]*$side[2]))-(2*$side[0]*$side[2]*cos($angle[1]))); $angle_a2 = rad2deg($angle_a2); $angle_b2 = rad2deg($angle_b2); echo "<BR>Angle A<sub>2</sub> = " ,$angle_a2, " degrees <BR>"; echo "Angle B<sub>2</sub> = " ,$angle_b2, " degrees <BR>"; echo "Side b<sub>2</sub> = " ,$side_b2, " units <BR>"; show_me_the_money($side, $angle); } elseif ($side[2] > $height && $side[2] >= $side[0]) //working! { echo "<BR>One solution, c > h and c > a.<BR>"; $angle[0] = asin(($side[0]*sin($angle[2]))/$side[2]); $angle[1] = $pi - $angle[0] - $angle[2]; $side[1] = sqrt((($side[0]*$side[0]) + ($side[2]*$side[2]))-(2*$side[0]*$side[2]*cos($angle[1]))); show_me_the_money($side, $angle); } elseif ($side[2] == $height) { echo "<BR>One solution, c = height.<BR>"; $angle[0] = ($pi/2); $angle[1] = $pi - $angle[0] - $angle[2]; $side[1] = $side[2]*tan($angle[1]); show_me_the_money($side, $angle); } } elseif ($angle[2] == ($pi/2)) //working! { echo "<BR>One solution, Angle C is 90 degrees.<BR>"; $side[1] = sqrt(($side[2]*$side[2]) - ($side[0]*$side[0])); $angle[0] = asin($side[0]*sin($angle[2])/$side[2]); $angle[1] = $pi - $angle[0] - $angle[2]; show_me_the_money($side, $angle); } } } //Side note: when I remove this line (just the '}') I get an "$end" error /// Why does the number of curly brackets not match up correctly -- yet still parses!!! //Line below is part that should be functioning, but isn't... elseif (empty($angle[2])) { if ($angle[0] > ($pi/2)) { die("KILLED"); if ($side[0] <= $side[2]) { echo "<BR>No solution because 'side is less than or equal to side '.<BR>"; } elseif ($side[1] > $side[2]) { echo "<BR>One Solution, b > c.<BR>"; $angle[2] = asin(($side[2]*sin($angle[1]))/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = ($side[0]*sin($angle[2]))/sin($angle[2]); show_me_the_money($side, $angle); } } elseif ($angle[1] < ($pi/2)) { $height = $side[2]*sin($angle[1]); if ($side[1] < $height) { echo "<BR>No solution, the swinging side (b) is shorter than the height.<BR>"; } elseif ($side[1] > $height && $side[1] < $side[2]) { echo "<BR>Two solutions, h < b < c.<BR>"; $angle[2] = asin(($side[2]*sin($angle[1]))/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $angle_c2 = $pi - $angle[2]; $angle_a2 = $pi - $angle[1] - $angle_c2; $side_a2 = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle_a2))); $side[0] = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[1]*cos($angle[0]))); $angle_c2 = rad2deg($angle_c2); $angle_a2 = rad2deg($angle_a2); echo "<BR>Angle C<sub>2</sub> = " ,$angle_c2, " degrees <BR>"; echo "Angle A<sub>2</sub> = " ,$angle_a2, " degrees <BR>"; echo "Side a<sub>2</sub> = " ,$side_a2, " units <BR>"; show_me_the_money($side, $angle); } elseif ($side[1] > $height && $side[1] >= $side[2]) { echo "<BR>One solution, b > h and b > c.<BR>"; $angle[2] = asin(($side[2]*sin($angle[1]))/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle[0]))); show_me_the_money($side, $angle); } elseif ($side[1] == $height) { echo "<BR>One solution, b = height.<BR>"; $angle[2] = ($pi/2); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = sqrt(($side[2]*$side[2]) - ($side[1]*$side[1])); show_me_the_money($side, $angle); } } elseif ($angle[1] == ($pi/2)) { echo "<BR>One Solution, Angle B is 90 degrees.<BR>"; $angle[2] = asin($side[2]/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = sqrt(($side[1]*$side[1]) - ($side[2]*$side[2])); show_me_the_money($side, $angle); } } elseif (empty($side[2])) { if (empty($angle[0])) { if ($angle[1] > ($pi/2)) { if ($side[1] <= $side[0]) { echo "<BR>No solution because 'side b is less than or equal to side a'.<BR>"; } elseif ($side[1] > $side[0]) { $angle[0] = asin(($side[0]*sin($angle[1]))/$side[1]); $angle[2] = $pi - $angle[0] - $angle[1]; $side[2] = ($side[1]*sin($angle[2]))/sin($angle[1]); show_me_the_money($side, $angle); } } elseif ($angle[1] < ($pi/2)) { $height = $side[0]*sin($angle[1]); if ($side[1] < $height) { echo "<BR>No solution, the swinging side (b) is shorter than the height.<BR>"; } elseif ($side[1] > $height && $side[1] < $side[0]) { echo "<BR>Two solutions, h < b < a ."; $angle[0] = asin(($side[0]*sin($angle[1]))/$side[1]); $angle[2] = $pi - $angle[1] - $angle[0]; $angle_a2 = $pi - $angle[0]; $angle_c2 = $pi - $angle[1] - $angle_a2; $side_c2 = sqrt((($side[0]*$side[0]) + ($side[1]*$side[1]))-(2*$side[0]*$side[1]*cos($angle_c2))); $side[2] = sqrt(($side[1]*$side[1]) + ($side[0]*$side[0])-(2*$side[1]*$side[0]*cos($angle[2]))); $angle_c2 = rad2deg($angle_c2); $angle_a2 = rad2deg($angle_a2); echo "<BR>Angle C<sub>2</sub> = " ,$angle_c2, " degrees <BR>"; echo "Angle A<sub>2</sub> = " ,$angle_a2, " degrees <BR>"; echo "Side c<sub>2</sub> = " ,$side_c2, " units <BR>"; show_me_the_money($side, $angle); } elseif ($side[1] > $height && $side[1] >= $side[0]) { echo "<BR>One solution, b > h and b > a.<BR>"; $angle[0] = asin(($side[0]*sin($angle[1]))/$side[1]); $angle[2] = $pi - $angle[1] - $angle[0]; $side[2] = sqrt((($side[1]*$side[1]) + ($side[0]*$side[0]))-(2*$side[1]*$side[0]*cos($angle[2]))); show_me_the_money($side, $angle); } elseif ($side[1] == $height) { echo "<BR>One solution, b = height.<BR>"; $angle[0] = ($pi/2); $angle[2] = $pi - $angle[1] - $angle[0]; $side[2] = sqrt(($side[0]*$side[0]) - ($side[1]*$side[1])); show_me_the_money($side, $angle); } } elseif ($angle[1] == ($pi/2)) { echo "<BR>One solution, Angle B is 90 degrees.<BR>"; $side[2] = sqrt(($side[1]*$side[1]) - ($side[0]*$side[0])); $angle[0] = asin($side[0]*sin($angle[1])/$side[1]); $angle[2] = $pi - $angle[1] - $angle[0]; show_me_the_money($side, $angle); } } } elseif (empty($angle[1])) { if ($angle[0] > ($pi/2)) { if ($side[0] <= $side[1]) { echo "<BR>No solution because 'side a is less than or equal to side b'.<BR>"; } elseif ($side[0] > $side[1]) { echo "<BR>One Solution, a > b.<BR>"; $angle[1] = asin(($side[1]*sin($angle[0]))/$side[0]); $angle[2] = $pi - $angle[1] - $angle[0]; $side[2] = ($side[0]*sin($angle[2]))/sin($angle[0]); show_me_the_money($side, $angle); } } elseif ($angle[0] < ($pi/2)) { $height = $side[1]*sin($angle[0]); if ($side[0] < $height) { echo "<BR>No solution, the swinging side (a) is shorter than the height.<BR>"; } elseif ($side[0] > $height && $side[0] < $side[1]) { echo "<BR>Two solutions, h < a < c."; $angle[1] = asin(($side[1]*sin($angle[0]))/$side[0]); $angle[2] = $pi - $angle[0] - $angle[1]; $angle_b2 = $pi - $angle[1]; $angle_c2 = $pi - $angle[0] - $angle_b2; $side_c2 = sqrt(($side[1]*$side[1]) + ($side[0]*$side[0])-(2*$side[1]*$side[0]*cos($angle_c2))); $side[2] = sqrt(($side[1]*$side[1]) + ($side[0]*$side[0])-(2*$side[0]*$side[1]*cos($angle[2]))); $angle_b2 = rad2deg($angle_c2); $angle_c2 = rad2deg($angle_a2); echo "<BR>Angle B<sub>2</sub> = " ,$angle_b2, " degrees <BR>"; echo "Angle C<sub>2</sub> = " ,$angle_c2, " degrees <BR>"; echo "Side c<sub>2</sub> = " ,$side_c2, " units <BR>"; show_me_the_money($side, $angle); } elseif ($side[0] > $height && $side[0] >= $side[1]) { echo "<BR>One solution, a > h and a > b.<BR>"; $angle[1] = asin(($side[1]*sin($angle[0]))/$side[0]); $angle[2] = $pi - $angle[0] - $angle[1]; $side[2] = sqrt(($side[1]*$side[1]) + ($side[0]*$side[0])-(2*$side[0]*$side[1]*cos($angle[2]))); show_me_the_money($side, $angle); } elseif ($side[0] == $height) { echo "<BR>One solution, a = height.<BR>"; $angle[1] = ($pi/2); $angle[2] = $pi - $angle[1] - $angle[0]; $side[2] = sqrt(($side[1]*$side[1]) - ($side[0]*$side[0])); show_me_the_money($side, $angle); } } elseif ($angle[0] == ($pi/2)) { echo "<BR>One Solution, Angle A is 90 degrees.<BR>"; $angle[1] = asin($side[1]/$side[0]); $angle[2] = $pi - $angle[0] - $angle[1]; $side[2] = sqrt(($side[0]*$side[0]) - ($side[1]*$side[1])); show_me_the_money($side, $angle); } } } function define_pi() { $pi = 3.14159265358979323846; return $pi; } #debug function show_me_the_money() {} ?> EDIT: as a side note, i ran this direct so no REQUEST's we're set Quote Link to comment https://forums.phpfreaks.com/topic/73135-solved-help-ive-made-a-dumb-mistake-but-i-dont-know-how/#findComment-369356 Share on other sites More sharing options...
lotrfan Posted October 14, 2007 Author Share Posted October 14, 2007 Well, you are right, this code works fine, but when I put the function into the rest of my script, it parses but doesn't do any work. I have no idea what is wrong. What situation would make only a certain part of a function's code work but not others? ??? Thanks again Quote Link to comment https://forums.phpfreaks.com/topic/73135-solved-help-ive-made-a-dumb-mistake-but-i-dont-know-how/#findComment-369466 Share on other sites More sharing options...
MadTechie Posted October 14, 2007 Share Posted October 14, 2007 the logic (mainly the if statements) if you can find values that work and values that do not work.. then you can workout the problem.. currently we need more info, to workout the problem, i suggest looking closely at the input.. Quote Link to comment https://forums.phpfreaks.com/topic/73135-solved-help-ive-made-a-dumb-mistake-but-i-dont-know-how/#findComment-369489 Share on other sites More sharing options...
lotrfan Posted October 14, 2007 Author Share Posted October 14, 2007 Whew! I got it! I finally realized that we were both right. There were the correct amount of total brackets {}, but not necessarily the right amount for each logic statement! There was one less } on one if statement, and one more } on a following statement, therefore allowing it parse -- but not to function at all. I can't believe we missed it, but here it is: function SSA($side, $angle) { $pi = define_pi(); if (empty($side[0])) { if (empty($angle[1])) { if ($angle[2] > ($pi/2)) { if ($side[2] <= $side[1]) //working! { echo "<BR>No solution because 'side c is less than or equal to side b'.<BR>"; } elseif ($side[2] > $side[1]) //working! { $angle[1] = asin(($side[1]*sin($angle[2]))/$side[2]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = ($side[2]*sin($angle[0])/sin($angle[2])); show_me_the_money($side, $angle); } } elseif ($angle[2] < ($pi/2)) { $height = $side[1]*sin($angle[2]); if ($side[2] < $height) //working! { echo "<BR>No solution, the swinging side (c) is shorter than the height.<BR>"; } elseif ($side[2] > $height && $side[2] < $side[1]) //working! { echo "<BR><i>Two solutions, h < c < b. </i><BR>"; $angle[1] = asin(($side[1]*sin($angle[2]))/$side[2]); $angle[0] = $pi - $angle[2] - $angle[1]; $angle_b2 = $pi - $angle[1]; $angle_a2 = $pi - $angle[2] - $angle_b2; $side_a2 = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle_a2))); $side[0] = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle[0]))); $angle_a2 = rad2deg($angle_a2); $angle_b2 = rad2deg($angle_b2); echo "<BR>Angle A<sub>2</sub> = " ,$angle_a2, " degrees <BR>"; echo "Angle B<sub>2</sub> = " ,$angle_b2, " degrees <BR>"; echo "Side a<sub>2</sub> = " ,$side_a2, " units <BR>"; show_me_the_money($side, $angle); } elseif ($side[2] > $height && $side[2] >= $side[1]) //working! { echo "<BR>One solution, c > h and c > b.<BR>"; $angle[1] = asin(($side[1]*sin($angle[2]))/$side[2]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = sqrt(($side[1]*$side[1] + $side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle[0]))); show_me_the_money($side, $angle); } elseif ($side[2] == $height) { echo "<BR>One solution, c = height.<BR>"; $angle[1] = ($pi/2); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = $side[2]*tan($angle[0]); show_me_the_money($side, $angle); } } elseif ($angle[2] == ($pi/2)) //working! { echo "<BR>One solution, Angle B is 90 degrees.<BR>"; $angle[1] = asin($side[1]/$side[2]); $angle[0] = $pi - $angle[2] - $angle[1]; $side[0] = sqrt(($side[2]*$side[2]) - ($side[1]*$side[1])); show_me_the_money($side, $angle); } } elseif (empty($angle[2])) { if ($angle[1] > ($pi/2)) { if ($side[1] <= $side[2]) //working! { echo "<BR>No solution because 'side b is less than or equal to side c'.<BR>"; } elseif ($side[1] > $side[2]) //working! { echo "<BR>One Solution, b > c.<BR>"; $angle[2] = asin(($side[2]*sin($angle[1]))/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = ($side[1]*sin($angle[0]))/sin($angle[1]); show_me_the_money($side, $angle); } } elseif ($angle[1] < ($pi/2)) { $height = $side[2]*sin($angle[1]); if ($side[1] < $height) //working! { echo "<BR>No solution, the swinging side (b) is shorter than the height.<BR>"; } elseif ($side[1] > $height && $side[1] < $side[2]) //working! { echo "<BR>Two solutions, h < b < c."; $angle[2] = asin(($side[2]*sin($angle[1]))/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $angle_c2 = $pi - $angle[2]; $angle_a2 = $pi - $angle[1] - $angle_c2; $side_a2 = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle_a2))); $side[0] = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle[0]))); $angle_c2 = rad2deg($angle_c2); $angle_a2 = rad2deg($angle_a2); echo "<BR>Angle C<sub>2</sub> = " ,$angle_c2, " degrees <BR>"; echo "Angle A<sub>2</sub> = " ,$angle_a2, " degrees <BR>"; echo "Side a<sub>2</sub> = " ,$side_a2, " units <BR>"; show_me_the_money($side, $angle); } elseif ($side[1] > $height && $side[1] >= $side[2]) //working! { echo "<BR>One solution, b > h and b > c.<BR>"; $angle[2] = asin(($side[2]*sin($angle[1]))/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle[0]))); show_me_the_money($side, $angle); } elseif ($side[1] == $height) { echo "<BR>One solution, b = height.<BR>"; $angle[2] = ($pi/2); $angle[0] = $pi - $angle[2] - $angle[1]; $side[0] = sqrt(($side[2]*$side[2]) - ($side[1]*$side[1])); show_me_the_money($side, $angle); } } elseif ($angle[1] == ($pi/2)) //working! { echo "<BR>One Solution, Angle B is 90 degrees.<BR>"; $angle[2] = acos($side[2]/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = sqrt(($side[1]*$side[1]) - ($side[2]*$side[2])); show_me_the_money($side, $angle); } } } elseif (empty($side[1])) { if (empty($angle[0])) { if ($angle[2] > ($pi/2)) { if ($side[2] <= $side[0]) //working! { echo "<BR>No solution because 'side a is less than or equal to side c'.<BR>"; } elseif ($side[2] > $side[0]) //working! { $angle[0] = asin(($side[0]*sin($angle[2]))/$side[2]); $angle[1] = $pi - $angle[0] - $angle[2]; $side[1] = sqrt(($side[0]*$side[0]) +($side[2]*$side[2]) - (2*$side[0]*$side[2]*cos($angle[1]))); show_me_the_money($side, $angle); } } elseif ($angle[2] < ($pi/2)) { $height = $side[0]*sin($angle[2]); if ($side[2] < $height) //working! { echo "<BR>No solution, the swinging side (c) is shorter than the height.<BR>"; } elseif ($side[2] > $height && $side[2] < $side[0]) //working! { echo "<BR>Two solutions, h < c < a.<BR>"; $angle[0] = asin(($side[0]*sin($angle[2]))/$side[2]); $angle[1] = $pi - $angle[0] - $angle[2]; $angle_a2 = $pi - $angle[0]; $angle_b2 = $pi - $angle[2] - $angle_a2; $side_b2 = sqrt((($side[0]*$side[0]) + ($side[2]*$side[2]))-(2*$side[0]*$side[2]*cos($angle_b2))); $side[1] = sqrt((($side[0]*$side[0]) + ($side[2]*$side[2]))-(2*$side[0]*$side[2]*cos($angle[1]))); $angle_a2 = rad2deg($angle_a2); $angle_b2 = rad2deg($angle_b2); echo "<BR>Angle A<sub>2</sub> = " ,$angle_a2, " degrees <BR>"; echo "Angle B<sub>2</sub> = " ,$angle_b2, " degrees <BR>"; echo "Side b<sub>2</sub> = " ,$side_b2, " units <BR>"; show_me_the_money($side, $angle); } elseif ($side[2] > $height && $side[2] >= $side[0]) //working! { echo "<BR>One solution, c > h and c > a.<BR>"; $angle[0] = asin(($side[0]*sin($angle[2]))/$side[2]); $angle[1] = $pi - $angle[0] - $angle[2]; $side[1] = sqrt((($side[0]*$side[0]) + ($side[2]*$side[2]))-(2*$side[0]*$side[2]*cos($angle[1]))); show_me_the_money($side, $angle); } elseif ($side[2] == $height) { echo "<BR>One solution, c = height.<BR>"; $angle[0] = ($pi/2); $angle[1] = $pi - $angle[0] - $angle[2]; $side[1] = $side[2]*tan($angle[1]); show_me_the_money($side, $angle); } } elseif ($angle[2] == ($pi/2)) //working! { echo "<BR>One solution, Angle C is 90 degrees.<BR>"; $side[1] = sqrt(($side[2]*$side[2]) - ($side[0]*$side[0])); $angle[0] = asin($side[0]*sin($angle[2])/$side[2]); $angle[1] = $pi - $angle[0] - $angle[2]; show_me_the_money($side, $angle); } } } //[s]Line below is part that should be functioning, but isn't...[/s] BUT IS NOW! elseif (empty($angle[2])) { if ($angle[0] > ($pi/2)) { if ($side[0] <= $side[2]) { echo "<BR>No solution because 'side is less than or equal to side '.<BR>"; } elseif ($side[1] > $side[2]) { echo "<BR>One Solution, b > c.<BR>"; $angle[2] = asin(($side[2]*sin($angle[1]))/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = ($side[0]*sin($angle[2]))/sin($angle[2]); show_me_the_money($side, $angle); } } elseif ($angle[1] < ($pi/2)) { $height = $side[2]*sin($angle[1]); if ($side[1] < $height) { echo "<BR>No solution, the swinging side (b) is shorter than the height.<BR>"; } elseif ($side[1] > $height && $side[1] < $side[2]) { echo "<BR>Two solutions, h < b < c.<BR>"; $angle[2] = asin(($side[2]*sin($angle[1]))/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $angle_c2 = $pi - $angle[2]; $angle_a2 = $pi - $angle[1] - $angle_c2; $side_a2 = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle_a2))); $side[0] = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[1]*cos($angle[0]))); $angle_c2 = rad2deg($angle_c2); $angle_a2 = rad2deg($angle_a2); echo "<BR>Angle C<sub>2</sub> = " ,$angle_c2, " degrees <BR>"; echo "Angle A<sub>2</sub> = " ,$angle_a2, " degrees <BR>"; echo "Side a<sub>2</sub> = " ,$side_a2, " units <BR>"; show_me_the_money($side, $angle); } elseif ($side[1] > $height && $side[1] >= $side[2]) { echo "<BR>One solution, b > h and b > c.<BR>"; $angle[2] = asin(($side[2]*sin($angle[1]))/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = sqrt(($side[1]*$side[1]) + ($side[2]*$side[2])-(2*$side[1]*$side[2]*cos($angle[0]))); show_me_the_money($side, $angle); } elseif ($side[1] == $height) { echo "<BR>One solution, b = height.<BR>"; $angle[2] = ($pi/2); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = sqrt(($side[2]*$side[2]) - ($side[1]*$side[1])); show_me_the_money($side, $angle); } } elseif ($angle[1] == ($pi/2)) { echo "<BR>One Solution, Angle B is 90 degrees.<BR>"; $angle[2] = asin($side[2]/$side[1]); $angle[0] = $pi - $angle[1] - $angle[2]; $side[0] = sqrt(($side[1]*$side[1]) - ($side[2]*$side[2])); show_me_the_money($side, $angle); } //There should have been another } here!!! } elseif (empty($side[2])) { if (empty($angle[0])) { if ($angle[1] > ($pi/2)) { if ($side[1] <= $side[0]) { echo "<BR>No solution because 'side b is less than or equal to side a'.<BR>"; } elseif ($side[1] > $side[0]) { $angle[0] = asin(($side[0]*sin($angle[1]))/$side[1]); $angle[2] = $pi - $angle[0] - $angle[1]; $side[2] = ($side[1]*sin($angle[2]))/sin($angle[1]); show_me_the_money($side, $angle); } } elseif ($angle[1] < ($pi/2)) { $height = $side[0]*sin($angle[1]); if ($side[1] < $height) { echo "<BR>No solution, the swinging side (b) is shorter than the height.<BR>"; } elseif ($side[1] > $height && $side[1] < $side[0]) { echo "<BR>Two solutions, h < b < a ."; $angle[0] = asin(($side[0]*sin($angle[1]))/$side[1]); $angle[2] = $pi - $angle[1] - $angle[0]; $angle_a2 = $pi - $angle[0]; $angle_c2 = $pi - $angle[1] - $angle_a2; $side_c2 = sqrt((($side[0]*$side[0]) + ($side[1]*$side[1]))-(2*$side[0]*$side[1]*cos($angle_c2))); $side[2] = sqrt(($side[1]*$side[1]) + ($side[0]*$side[0])-(2*$side[1]*$side[0]*cos($angle[2]))); $angle_c2 = rad2deg($angle_c2); $angle_a2 = rad2deg($angle_a2); echo "<BR>Angle C<sub>2</sub> = " ,$angle_c2, " degrees <BR>"; echo "Angle A<sub>2</sub> = " ,$angle_a2, " degrees <BR>"; echo "Side c<sub>2</sub> = " ,$side_c2, " units <BR>"; show_me_the_money($side, $angle); } elseif ($side[1] > $height && $side[1] >= $side[0]) { echo "<BR>One solution, b > h and b > a.<BR>"; $angle[0] = asin(($side[0]*sin($angle[1]))/$side[1]); $angle[2] = $pi - $angle[1] - $angle[0]; $side[2] = sqrt((($side[1]*$side[1]) + ($side[0]*$side[0]))-(2*$side[1]*$side[0]*cos($angle[2]))); show_me_the_money($side, $angle); } elseif ($side[1] == $height) { echo "<BR>One solution, b = height.<BR>"; $angle[0] = ($pi/2); $angle[2] = $pi - $angle[1] - $angle[0]; $side[2] = sqrt(($side[0]*$side[0]) - ($side[1]*$side[1])); show_me_the_money($side, $angle); } } elseif ($angle[1] == ($pi/2)) { echo "<BR>One solution, Angle B is 90 degrees.<BR>"; $side[2] = sqrt(($side[1]*$side[1]) - ($side[0]*$side[0])); $angle[0] = asin($side[0]*sin($angle[1])/$side[1]); $angle[2] = $pi - $angle[1] - $angle[0]; show_me_the_money($side, $angle); } } } elseif (empty($angle[1])) { if ($angle[0] > ($pi/2)) { if ($side[0] <= $side[1]) { echo "<BR>No solution because 'side a is less than or equal to side b'.<BR>"; } elseif ($side[0] > $side[1]) { echo "<BR>One Solution, a > b.<BR>"; $angle[1] = asin(($side[1]*sin($angle[0]))/$side[0]); $angle[2] = $pi - $angle[1] - $angle[0]; $side[2] = ($side[0]*sin($angle[2]))/sin($angle[0]); show_me_the_money($side, $angle); } } elseif ($angle[0] < ($pi/2)) { $height = $side[1]*sin($angle[0]); if ($side[0] < $height) { echo "<BR>No solution, the swinging side (a) is shorter than the height.<BR>"; } elseif ($side[0] > $height && $side[0] < $side[1]) { echo "<BR>Two solutions, h < a < c."; $angle[1] = asin(($side[1]*sin($angle[0]))/$side[0]); $angle[2] = $pi - $angle[0] - $angle[1]; $angle_b2 = $pi - $angle[1]; $angle_c2 = $pi - $angle[0] - $angle_b2; $side_c2 = sqrt(($side[1]*$side[1]) + ($side[0]*$side[0])-(2*$side[1]*$side[0]*cos($angle_c2))); $side[2] = sqrt(($side[1]*$side[1]) + ($side[0]*$side[0])-(2*$side[0]*$side[1]*cos($angle[2]))); $angle_b2 = rad2deg($angle_c2); $angle_c2 = rad2deg($angle_a2); echo "<BR>Angle B<sub>2</sub> = " ,$angle_b2, " degrees <BR>"; echo "Angle C<sub>2</sub> = " ,$angle_c2, " degrees <BR>"; echo "Side c<sub>2</sub> = " ,$side_c2, " units <BR>"; show_me_the_money($side, $angle); } elseif ($side[0] > $height && $side[0] >= $side[1]) { echo "<BR>One solution, a > h and a > b.<BR>"; $angle[1] = asin(($side[1]*sin($angle[0]))/$side[0]); $angle[2] = $pi - $angle[0] - $angle[1]; $side[2] = sqrt(($side[1]*$side[1]) + ($side[0]*$side[0])-(2*$side[0]*$side[1]*cos($angle[2]))); show_me_the_money($side, $angle); } elseif ($side[0] == $height) { echo "<BR>One solution, a = height.<BR>"; $angle[1] = ($pi/2); $angle[2] = $pi - $angle[1] - $angle[0]; $side[2] = sqrt(($side[1]*$side[1]) - ($side[0]*$side[0])); show_me_the_money($side, $angle); } } elseif ($angle[0] == ($pi/2)) { echo "<BR>One Solution, Angle A is 90 degrees.<BR>"; $angle[1] = asin($side[1]/$side[0]); $angle[2] = $pi - $angle[0] - $angle[1]; $side[2] = sqrt(($side[0]*$side[0]) - ($side[1]*$side[1])); show_me_the_money($side, $angle); } } } Thanks for the help though, MadTechie, you still helped to lead me in the right direction. Once you said that the brace number was right -- combined with my observation that the statement didn't have enough -- planted the idea in my head. Thanks all! ***By the way, MadTechie, how did you find the exact number of brackets? Count them out by hand? Quote Link to comment https://forums.phpfreaks.com/topic/73135-solved-help-ive-made-a-dumb-mistake-but-i-dont-know-how/#findComment-369548 Share on other sites More sharing options...
MadTechie Posted October 15, 2007 Share Posted October 15, 2007 ***By the way, MadTechie, how did you find the exact number of brackets? Count them out by hand? LOL, thats sounds too much like work to me, i copied the code in Dreamweaver, then done a find all on {, in the list i reviewed the line, (to check if any were commented out) this also gave me the total number, i then did the same for the } Quote Link to comment https://forums.phpfreaks.com/topic/73135-solved-help-ive-made-a-dumb-mistake-but-i-dont-know-how/#findComment-369621 Share on other sites More sharing options...
lotrfan Posted October 15, 2007 Author Share Posted October 15, 2007 OH...ROFL!!! To think I actually used tally marks on paper (gasp) to count them out! I feel kind of silly. I think I'll just use Dreamweaver from now on.... Quote Link to comment https://forums.phpfreaks.com/topic/73135-solved-help-ive-made-a-dumb-mistake-but-i-dont-know-how/#findComment-369624 Share on other sites More sharing options...
MadTechie Posted October 15, 2007 Share Posted October 15, 2007 you can use any, i just had that installed on this machine, their are better but i got used to this another good one for 90% of text editing is Notepad++ (google it) Quote Link to comment https://forums.phpfreaks.com/topic/73135-solved-help-ive-made-a-dumb-mistake-but-i-dont-know-how/#findComment-369628 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.