Codey Posted May 6, 2014 Share Posted May 6, 2014 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 More sharing options...
Jacques1 Posted May 6, 2014 Share Posted May 6, 2014 Your if statement lacks a closing parenthesis. But the actual problem is that you write code with all error messages turned off. Go to the php.ini and set display_errors to On and error_reporting to -1. Link to comment https://forums.phpfreaks.com/topic/288281-php-code-error/#findComment-1478393 Share on other sites More sharing options...
Ch0cu3r Posted May 6, 2014 Share Posted May 6, 2014 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 More sharing options...
Codey Posted May 6, 2014 Author Share Posted May 6, 2014 Thank you for the help, problem solved ! Link to comment https://forums.phpfreaks.com/topic/288281-php-code-error/#findComment-1478418 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.