Erreurs de syntaxe sur requêtes DELETE
Bonjour, voila j'ai 1 souci, je souhaite à l'aide de 2 boutons supprimer 1 fichier à la fois en tant que donnée, et son enregistrement lié ds la bdd. Puis je souhaite supprimer 1 fiche ( renseignement contenu dans la bdd). Seulement le code suivant, efface bien le fichier du dossier, mais pas les enregistrement.
Quand je supprime 1 fichier j'ai:
Code:
1 2
| Erreur : DELETE * from fichiersj where nomFichierj ='bienvenue.jpg'
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 '* from fichiersj where nomFichierj ='bienvenue.jpg'' at line 1 |
avec le code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| <?php
include ('secure.php');
include ('mysqlconnect.php');
$nomFichier = $_POST['la_valeur'];
$numfiche = $_POST['textfield'];
if(empty($nomFichier))
{
$msg="Erreur: Pas de fichiers";
}else
{
$fichier = 'C:\wamp\www\rbdc\upload/'.$nomFichier.'';
$dir = 'C:\wamp\www\rbdc\upload/';
$tailleFichier = filesize($fichier);
//suppression fichier
unlink($fichier);
//efface le fichier dans la bdd
$sqlsupr = "DELETE * from fichiersj where nomFichierj ='".$nomFichier."'";
$reqsupr = mysql_query($sqlsupr) or die("Erreur : ".$sqlsupr.'<br/>'. mysql_error());
$msg = "Fichier \''$nomFichier'\' supprimé";
}
echo '<script language=javascript> alert ("\''.$msg.'\'");</script>';
echo '<SCRIPT LANGUAGE="JavaScript">
document.location.href="accueil.php" </SCRIPT>';
exit;
?> |
et quand je supprime 1 fiche j'ai
Code:
1 2
| Erreur : DELETE * from fichiersj where numFiche = '36'
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 '* from fichiersj where numFiche = '36'' at line 1 |
avec le code
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| <?php
include ('secure.php');
//connection à la base
include ('mysqlconnect.php');
$numfiche = $_POST['textfield'];
$sql = "SELECT * FROM fiches WHERE numFiche = '".$numfiche."'";
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
$data = mysql_fetch_array($req);
if($data['numFiche'] == $numfiche)
{
//suppression fiches
$requete = "DELETE * FROM fiches WHERE numFiche = '".$numfiche."'" ;
$resultat = mysql_query($requete);
//suppression fichiers
$sqlsupr = "DELETE * from fichiersj where numFiche = '".$numfiche."'";
$reqsupr = mysql_query($sqlsupr) or die("Erreur : ".$sqlsupr.'<br/>'. mysql_error());
$msg = "La fiche n°\''$numfiche'\' a été supprimer";
}else{
$msg="Erreur, aucune fiche n'a été trouvée";
}
echo '<script language=javascript> alert (" \''.$msg.'\' ");</script>';
echo '<SCRIPT LANGUAGE="JavaScript">
document.location.href="accueil.php" </SCRIPT>';
exit;
?> |
Je ne trouve pas la solution. :?