The request of my function has a problem:
function rdvDelete($rdv)
{
$pdo = connexion();
$sql = $pdo->prepare("DELETE FROM visitors,rdvs WHERE rdvs.idRdv = :rdv AND visitors.idVisitor = rdvs.idVisitor"); <-- line 34
$sql->execute(['rdv' => $rdv]);
}
$rdv = 3 !!!
And this display this error
[error] 639#639: *9791 FastCGI sent in stderr: "PHP message: PHP Fatal
error: Uncaught PDOException: 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 rdvs.idRdv = ? AND visitors.idVisitor =
rdvs.idVisitor’ at line 1 in
/var/www/MY-WEBSITE/model/m_manage-rdvs.php:34
Thanks
3
Answers
I solved my problem with this query :
I believe your prepared statement has an error. You need to specify both parameters in the statement before executing with the actual values of the parameters. Do this
SQLite does not support explicit or implicit joins in
DELETE
statements. You are attempting the implicit join with comma separated tables inFROM
clause and join condition inWHERE
. For correlated delete statements, consider usingIN
orEXISTS
operators on a subquery: