Jump to content

PHP Code Error


Codey

Recommended Posts

Hello

 

Hope some one can guide me in the right direction, am working on a simple PHP Calculator.

 

Been trying to find the problem for quite some hours all I get is a blank page, and have not been able to spot the issue, here is the code:

 

<html> 
  <head>
  
  <title></title> 
  
  </head> 
  
  <body>
  
<?php 


$operacion = $_POST['lista'];




if (isset($_POST['c1']) && !empty($_POST['c1']) &&


isset($_POST['c2']) && !empty($_POST['c2']) &&


isset($_POST['c3']) && !empty($_POST['c3'])


echo "El resultado es";


else {
echo "debes insertar todos los campos"; }


switch($operacion) {


case sumar:
echo $_POST['c1'] + $_POST['c2'] + $_POST['c3']; 
break;


case restar:
echo $_POST['c1'] - $_POST['c2'] - $_POST['c3']; 
break;


case multiplicar:
echo $_POST['c1'] * $_POST['c2'] * $_POST['c3']; 
break;


case dividir:
echo $_POST['c1'] / $_POST['c2'] / $_POST['c3']; 
break;


default: "no se ha podido realizar la operacion"; 


}



?>
  
</body> 
</html> 

Any help would be appreciated, thank you.

 

Link to comment
https://forums.phpfreaks.com/topic/288281-php-code-error/
Share on other sites

 

 

all I get is a blank page,

Turn error reporting on, open the php.ini and make sure display_errors is set to on and error_reporting is set to E_ALL

 

On line 18 - 24 you have a malformed if statement. Have left off the closing parenthesis for the condition and a opening { (curly brace) for the statement.

On line 29 before the else you have left of the closing  } (curly brace) for closing the if statement

 

Refer to the manual for the proper structure for an if/esle

 

The values for each case statement should be wrapped in quotes

Link to comment
https://forums.phpfreaks.com/topic/288281-php-code-error/#findComment-1478395
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.