I have a problem with a exam online that execut this error: "in /storage/ssd4/822/13313822/public_html/examen/controlador/examenControl.php on line 11"
The examenControl.php is:
<?php
session_start();
require_once "../ruta.php";
require_once $_SERVER['DOCUMENT_ROOT'].ruta::ruta. '/Modelo/Beans/examen.php';
require_once $_SERVER['DOCUMENT_ROOT'].ruta::ruta. '/Modelo/Bo/examenBo.php';
switch ($_REQUEST['action']) {
case "evalua":
$examen=new examen();
$examen->suma=$_POST['sum']+$_POST['sum2']+$_POST['sum3']+$_POST['sum4']+$_POST['sum5']+$_POST['sum6']+$_POST['sum7']+$_POST['sum8']+$_POST['sum9']+$_POST['sum10'];
$examen->r1=$_POST['sum'];
$examen->r2=$_POST['sum2'];
$examen->r3=$_POST['sum3'];
$examen->r4=$_POST['sum4'];
$examen->r5=$_POST['sum5'];
$examen->r6=$_POST['sum6'];
$examen->r7=$_POST['sum7'];
$examen->r8=$_POST['sum8'];
$examen->r9=$_POST['sum9'];
$examen->r10=$_POST['sum10'];
$examen->id= $_SESSION['idaspirante'];
$bo=new examenBo();
$r = $bo->registrarResultadoBo($examen);
print($r);
break;
}
?>
I think the problem is of a value other than 0, but I don't know how to solve. How can solve the problem?
Thanks.
You can solve the error by converting you inputs to numeric values but it will be better to check those inputs and return an error if there are not the type of values you want
$examen->suma = floatval($_POST['sum']) + floatval($_POST['sum2']) + floatval($_POST['sum3']) + floatval($_POST['sum4']) + floatval($_POST['sum5']) + floatval($_POST['sum6']) + floatval($_POST['sum7']) + floatval($_POST['sum8']) + floatval($_POST['sum9']) + floatval($_POST['sum10']);