message erreur avec 2 requetes prepare
voila j'ai une liste deroulante et un bouton monter pour au clic de monter la photo de position
donc en premier je monte l'id de l'image et en second partie l'id de l'image d'avant doit elle descendre.
En gros il interverti pour eviter les erreurs.
mais j'ai un message d'erreur:
Code:
1 2
|
Fatal error: Uncaught exception 'PDOException' with message '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 'WHERE id=6' at line 3' in C:\wamp\www\simplimmo\lib\IllustrationManager_PDO.class.php:291 Stack trace: #0 C:\wamp\www\simplimmo\lib\IllustrationManager_PDO.class.php(291): PDOStatement->execute() #1 C:\wamp\www\simplimmo\backend\gest_galerie.php(45): IllustrationManager_PDO->monter(5, 3, 6, 5) #2 {main} thrown in C:\wamp\www\simplimmo\lib\IllustrationManager_PDO.class.php on line 291 |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
<?php
public function monter($id1,$position1,$id2,$posistion2)
{
/**monter l'id de postion*/
$requete1 = $this->db->prepare('UPDATE simplimmo_galerie SET
position='.$position1.'
WHERE id='.$id1.'');
$requete1->execute();
/*descent la position de l'id qui avait la position de la 1 fonction*/
$requete2 = $this->db->prepare('UPDATE simplimmo_galerie SET
position='.$position2.'
WHERE id='.$id2.'');
$requete2->execute();
}?> |
merci.