Jump to content

[SOLVED] $end error


doucettej3

Recommended Posts

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;
}
?>

Link to comment
https://forums.phpfreaks.com/topic/128386-solved-end-error/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.