doucettej3 Posted October 14, 2008 Share Posted October 14, 2008 im trying to make the program output the result from one of my functions and it leaves out the result in the output. so it says the sum of 1-x is blank. 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; } } ?> EDIT: Please use the code tags ( ) when posting code Link to comment https://forums.phpfreaks.com/topic/128391-solved-output-error/ Share on other sites More sharing options...
Orio Posted October 14, 2008 Share Posted October 14, 2008 <?php $result = sum_even($even_m); //Should be: $result = sum_even($even_max); ?> Orio. Link to comment https://forums.phpfreaks.com/topic/128391-solved-output-error/#findComment-665210 Share on other sites More sharing options...
doucettej3 Posted October 14, 2008 Author Share Posted October 14, 2008 Thank you i need to stop goin thru so fast. Link to comment https://forums.phpfreaks.com/topic/128391-solved-output-error/#findComment-665220 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.