doucettej3 Posted October 14, 2008 Share Posted October 14, 2008 Hey im new at php..i just started my programmin class in college and i keep getting a $end error in my lab. any suggestions would be nice. heres the code: <?php { $action = $_POST['action']; $even_max = $_POST['even_max']; $odd_max = $_POST['odd_max']; $variable1 = $_POST['variable1']; $variable2 = $_POST['variable2']; function sum_even($even_m) { $count = 0; while($even_max > $count) { $count = $count + 2; $sum = $sum + $count; } return $sum; } function sum_odd($odd_m) { $count = 1; while($odd_max > $count) { $count = $count + 2; $sum = $sum + $count; } return $sum; } function exponent($variable1, $variable2) { $count = 0; while ($count < $variable2) { $count= $count + 1; $answer = $variable1 * $variable1; } return $answer; } switch($action) { case 'even': $even_max = $_POST['even_max']; $result = sum_even($even_m); echo "The sum of all the numbers between 1-$even_max is $result"; break; } ?> Quote Link to comment Share on other sites More sharing options...
discomatt Posted October 14, 2008 Share Posted October 14, 2008 I count 8 opening curly braces ( { ) and only 7 closing curly braces ( } ) Quote Link to comment Share on other sites More sharing options...
Zhadus Posted October 14, 2008 Share Posted October 14, 2008 $end error means you have a bracket that's left open. The { bracket at the beginning after you use <?php is not needed and is causing the problem from what I can tell, although I'm not sure what the whole switch() thing is about. Quote Link to comment Share on other sites More sharing options...
Andy17 Posted October 14, 2008 Share Posted October 14, 2008 You start by opening a bracket in line 2 but you never close it again. Just remove the opening brace in line two and you should be good. Quote Link to comment Share on other sites More sharing options...
doucettej3 Posted October 14, 2008 Author Share Posted October 14, 2008 yea that fixed it thanx alot guys Quote Link to comment Share on other sites More sharing options...
Brian W Posted October 14, 2008 Share Posted October 14, 2008 please mark as SOLVED. thank you and best of luck. Quote Link to comment 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.