Rosamunda Rosamunda - 7 months ago 30
MySQL Question

PDO->execute() statement won't work and is syntactically correct

I can't understand why this PDO statements won't save anything into the database:

//guardamos en base
$conectar2 = new PDO('mysql:host='.HOST.'; dbname='.DATABASE.'; charset=utf8', USER, PASS);
$agregarData = $conectar2->prepare("
UPDATE mensajes
SET estadoMensaje = ?,
datosMensaje = ?
WHERE mensajeID = ?;
$agregarData->bindParam(1, $estadoMensaje);
$agregarData->bindParam(2, $data);
$agregarData->bindParam(3, $mensajeID);

echo '<br>Mensaje actualizado.';

My error log won't say anything. Anything out of place that I could have missed?

I've tried the sql statement into mysql by hand and it works.

I've echoed the variables and they are not empty (they are all strings).

The connection does work.

What am I missing?


You began a transaction but forgot to commit it.



after issuing your queries will fix the problem.

You might consider removing the transaction altogether if there are no other queries being issued.