I get this error when I run the application:
SQLSTATE [42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 'in C: \ wamp64 \ www \ workcollaborative \ appcollaborative \ dao \ DaoSolicitud.php: 78 Stack trace: # 0 C: \ wamp64 \ www \ collaborative work \ applaboratory \ dao \ DaoSolicitud.php (78): PDOStatement-> execute () # 1 C: \ wamp64 \ www \ collaborative work \ applaboratory \ web \ controller.php (193): DaoRequest- > unsubscribe (NULL) # 2 {main}
The case is when you give a fixed value if you execute everything correctly.
For example $ordenSql = "DELETE FROM solicitud WHERE tarea_id=2";
public function desapuntarse($tarea_id) {
$conexion = new Conexion();
$objPDO = $conexion->getPDO();
$ordenSql = "DELETE FROM solicitud WHERE tarea_id=$tarea_id";
$statement = $objPDO->prepare($ordenSql);
$statement->bindValue(':tarea_id', $tarea_id, PDO::PARAM_STR);
try {
$objPDO->beginTransaction();
$statement->execute();
$objPDO->commit();
} catch (PDOException $e) {
throw ($e);
} finally {
$statement = NULL;
$objPDO = NULL;
}
}
case "desapuntarse":
$dao = new DaoSolicitud();
$tarea_id = $_REQUEST['tarea_id'];
try {
$dao->Desapuntarse($tarea_id);
$desapuntarse = $dao->desapuntarse();
$_SESSION['desapuntarse'] = $desapuntarse;
header('Location: desplegartarea.php');
} catch (PDOException $e) {
print ($e);
}
break;