I am developing a API
with slim framework 3
that connects to a base de datos
local. The problem is the following when I try to update an element of my BD
by passing it a id
said procedure returns the following error "{" error ": {" text ": SQLSTATE [42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'where idService = 1' at line 2} "
specialty.php
<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
$app->group('/especialidad/', function () {
$this-> put('actualizar/{id}', function(Request $request, Response $response){
$id = $request->getAttribute('id');
$nombre = $request->getParam('nombre');
$sql = "update especialidad set nombre =:nombre ,
where idEspecialidad = $id";
try{
$db = new db();
$db = $db->connect();
$stmt = $db->prepare($sql);
$stmt->bindParam(':nombre', $_POST['nombre'], PDO::PARAM_STR);
$stmt->execute();
$db = null;
echo '{"notice": {"text": "Especialidad Actualizada"}';
} catch(PDOException $e){
echo '{"error": {"text": '.$e->getMessage(). '}';
}
});
});