Problem update
stefanelle
-
toto -
toto -
Bonjour,
j ai un fichier php qui m affiche un tableau avec des valeurs de champs que je peux modifier mais j ai un problème avec mon update ça me renvois l erreur suivante ...
Erreur SQL !
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 ' reference='55548',artiste='Boyracer/Cannanes/Mytty Archer',album='Split',format' at line 1
et voila mon fichier merci
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Catalogue</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body link="#000000" vlink="#FFFFFF" alink="#FFFFFF">
<div id="body">
<?php
include ('config.php');
include ('connexion.php');
//nom_label
$nom_label = $_POST["nom_label"] ;
//reference
$reference = $_POST["reference"];
$sql1 = "SELECT contenu.reference, contenu.artiste, contenu.album, contenu.format, label.nom_label FROM contenu, label WHERE label.id_label = contenu.id_label AND label.nom_label = '".$_POST
['nom_label']."' ";
$req1= mysql_query($sql1) or die( mysql_error() ) ;
$total = mysql_num_rows($req1);
if($total!=0)
{
echo '<form method ="post" action="modif2.php">';
echo '<table>'."\n";
echo '<tr>';
echo '<td ><b><u>Label</u></b></td>';
echo '<td ><b><u>reference</u></b></td>';
echo '<td><b><u>artiste</u></b></td>';
echo '<td><b><u>album</u></b></td>';
echo '<td><b><u>format</u></b></td>';
echo '</tr>'."\n";
while($row = mysql_fetch_array($req1))
{
echo '<tr>';
echo '<td><input type="text" name="nom_label" value="'.$row ["nom_label"].'"/></td>';
echo '<td><input type="text" name="reference" value="'.$row ["reference"].'"/></td>';
echo '<td><input type="text" name="artiste" value="'.$row["artiste"].'"/></td>';
echo '<td><input type="text" name="album" value="'.$row["album"].'"/></td>';
echo '<td><input type="text" name="format" value="'.$row["format"].'"/></td>';
echo '</tr>'."\n";
}
echo '</table>'."\n";
echo '<input type="submit" name="btOk" value="Modifier!"/>';
echo '</form>';
if (isset($_POST['btOk']))
{
$sql3= "UPDATE label, contenu SET nom_label='".$_POST['nom_label']."' WHERE nom_label='".$nom_label."', reference='".$_POST['reference']."',artiste='".$_POST['artiste']."',album='".$_POST
['album']."',format='".$_POST['format']."' WHERE reference ='".$reference."'";
$req3= mysql_query($sql3) or die('Erreur SQL !'.$sql2.'<br>'.mysql_error());
if($req3)
{
echo ("L'insertion a été correctement effectuée") ;
}
else
{
echo("L'insertion à échouée") ;
}
}
}
?>
</body></html>
<?php
mysql_close();
?>
j ai un fichier php qui m affiche un tableau avec des valeurs de champs que je peux modifier mais j ai un problème avec mon update ça me renvois l erreur suivante ...
Erreur SQL !
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 ' reference='55548',artiste='Boyracer/Cannanes/Mytty Archer',album='Split',format' at line 1
et voila mon fichier merci
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Catalogue</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body link="#000000" vlink="#FFFFFF" alink="#FFFFFF">
<div id="body">
<?php
include ('config.php');
include ('connexion.php');
//nom_label
$nom_label = $_POST["nom_label"] ;
//reference
$reference = $_POST["reference"];
$sql1 = "SELECT contenu.reference, contenu.artiste, contenu.album, contenu.format, label.nom_label FROM contenu, label WHERE label.id_label = contenu.id_label AND label.nom_label = '".$_POST
['nom_label']."' ";
$req1= mysql_query($sql1) or die( mysql_error() ) ;
$total = mysql_num_rows($req1);
if($total!=0)
{
echo '<form method ="post" action="modif2.php">';
echo '<table>'."\n";
echo '<tr>';
echo '<td ><b><u>Label</u></b></td>';
echo '<td ><b><u>reference</u></b></td>';
echo '<td><b><u>artiste</u></b></td>';
echo '<td><b><u>album</u></b></td>';
echo '<td><b><u>format</u></b></td>';
echo '</tr>'."\n";
while($row = mysql_fetch_array($req1))
{
echo '<tr>';
echo '<td><input type="text" name="nom_label" value="'.$row ["nom_label"].'"/></td>';
echo '<td><input type="text" name="reference" value="'.$row ["reference"].'"/></td>';
echo '<td><input type="text" name="artiste" value="'.$row["artiste"].'"/></td>';
echo '<td><input type="text" name="album" value="'.$row["album"].'"/></td>';
echo '<td><input type="text" name="format" value="'.$row["format"].'"/></td>';
echo '</tr>'."\n";
}
echo '</table>'."\n";
echo '<input type="submit" name="btOk" value="Modifier!"/>';
echo '</form>';
if (isset($_POST['btOk']))
{
$sql3= "UPDATE label, contenu SET nom_label='".$_POST['nom_label']."' WHERE nom_label='".$nom_label."', reference='".$_POST['reference']."',artiste='".$_POST['artiste']."',album='".$_POST
['album']."',format='".$_POST['format']."' WHERE reference ='".$reference."'";
$req3= mysql_query($sql3) or die('Erreur SQL !'.$sql2.'<br>'.mysql_error());
if($req3)
{
echo ("L'insertion a été correctement effectuée") ;
}
else
{
echo("L'insertion à échouée") ;
}
}
}
?>
</body></html>
<?php
mysql_close();
?>
A voir également:
- Problem update
- Windows update bloqué - Guide
- Winget update - Guide
- Asus live update - Télécharger - Utilitaires
- Wsus offline update - Télécharger - Systèmes d'exploitation
- Windows update windows 10 - Guide
3 réponses
bonjour j ai fait une modif avec une clause where mais voila le message je suis perdu ...
Erreur SQL !
Duplicate entry 'ABR003' for key 1
$sql3= "UPDATE
label, contenu
SET
nom_label='".$nom_label."', reference='".$_POST['reference']."',
artiste='".$_POST['artiste']."',album='".$_POST['album']."',
format='".$_POST['format']."', reference ='".$reference."'
WHERE
nom_label='".$_POST['nom_label']."'";
Erreur SQL !
Duplicate entry 'ABR003' for key 1
$sql3= "UPDATE
label, contenu
SET
nom_label='".$nom_label."', reference='".$_POST['reference']."',
artiste='".$_POST['artiste']."',album='".$_POST['album']."',
format='".$_POST['format']."', reference ='".$reference."'
WHERE
nom_label='".$_POST['nom_label']."'";