Problème de syntaxe SQL (UPDATE)
Bonjour à tous, comme le notifie le titre, je viens vers vous car j'ai un petit souci de syntaxe, que j'ai essayé de résoudre toute l'après midi...
Bon je vous expose donc mon problème :
J'ai une table au sein d'une base de donnée, qui contient 'X' entrées, les entrées en question sont des films, chaque entrée est dotée de 'X' champs, correspondant aux informations sur le film ( Ex: champ1: ID , champ2: titre , champ3 : description , etc.. )
J'ai donc voulu créer une page qui me permettrai de mettre à jour ces informations, via un formulaire.
Seulement voilà, il me semble que tout devrais fonctionner, aussi bien côté formulaire html, que script php...
Mais je ne serait pas ici si c'était le cas, n'est-ce pas ? ;)
Donc voici l'erreur générée par le script :
Code:
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 '(titre, description, image, link, link2, link3, allocine, lien_torrent, people, ' at line 1
Sachant que, après 'people' devrait suivre 'language, genre, qualité)' ...
Ici, c'est côté script :
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 26 27 28 29 30 31
| <?php
if(isset($_POST['txtTitre'])){
$query = " UPDATE films(titre, description, image, link, link2, link3, allocine, lien_torrent, people, language, genre, qualité)
VALUES (
'".$_POST["txtTitre"]."',
'".$_POST["txtDescription"]."',
'".$_POST["txtImage"]."',
'".$_POST["txtMegaupload"]."',
'".$_POST["txtMegavideo"]."',
'".$_POST["txtVideobb"]."',
'".$_POST["txtAllocine"]."',
'".$_POST["txtUtorrent"]."',
'".$_POST["txtPeople"]."',
'".$_POST["cboLanguage"]."',
'".$_POST["rbtnGenre"]."',
'".$_POST["rbtnQual"]."') WHERE id = '". $_POST['txtId']."' ";
//echo $query;
mysql_connect('XXXXXXXXXXXXX','XXXXXXXXXX','XXXXXXXX') or die(mysql_error());
mysql_select_db(XXXXXXXXXX) or die(mysql_error());
mysql_query($query)
or die(mysql_error());
@mysql_close($connection);
echo "Le film $titre a été ajouté \n";
}
?> |
Et enfin le formulaire :
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
| <?php
require('include/config.php');
function getFilm ($idfilm) {
$sel = "SELECT * FROM films WHERE ID = ".$idfilm;
$res = mysql_query($sel);
while ($data = mysql_fetch_assoc($res)) $tab[]=$data ;
return $tab;
}
?><?php
if(isset($_GET['id']))
$leFilm = getFilm ($_GET['id']) ;
foreach($leFilm as $key=>$film):
?>
<div class="formulaire_fl">
<form method="post" action="#" name="insertForm" enctype="multipart/form-data">
<table>
<tfoot>
<tr>
<th colspan="5" align="right" class="tblFooters">
</th>
</tr>
</tfoot>
<tbody>
<input type="text" value="<?php echo $film['id'] ;?>" name="txtId" id="txtId" hidden /> // je récupère et cache l'id du film
<tr>
<td align="center">
Titre
</td>
<td>
<input type="text" name="txtTitre" id="txtTitre" value="<?php echo $film['titre']; ?>" size="40" MAXLENGTH=255 class="textfield" />
</td>
</tr>
<tr>
<td align="center">
Description <br /> Résumé / synospis
</td>
<td>
<textarea name="txtDescription" id="txtDescription" rows="7" cols="40" dir="ltr" ><?php echo $film['description']; ?></textarea>
</td>
</tr>
<tr>
<td align="center">
Lien Image
</td>
<td>
<input type="text" name="txtImage" id="txtImage" value="<?php echo $film['image']; ?>" size="40" MAXLENGTH=255 class="textfield"/>
</td>
</tr>
<tr>
<td align="center">
Lien MEGAUPLOAD
</td>
<td>
<input type="text" name="txtMegaupload" id="txtMegaupload" value="<?php echo $film['link']; ?>" size="40" MAXLENGTH=255 class="textfield" />
</td>
</tr>
<tr>
<td align="center">
Lien MEGAVIDEO
</td>
<td>
<input type="text" name="txtMegavideo" id="txtMegavideo" value="<?php echo $film['link2']; ?>" size="40" MAXLENGTH=255 class="textfield" />
</td>
</tr>
<td align="center">
Lien VideoBB
</td>
<td>
<input type="text" name="txtVideobb" id="txtVideobb" value="<?php echo $film['link3']; ?>" size="40" MAXLENGTH=255 class="textfield" />
</td>
</tr>
<tr>
<td align="center">
Lien Allociné
</td>
<td>
<input type="text" name="txtAllocine" id="txtAllocine" value="<?php echo $film['allocine']; ?>" size="40" MAXLENGTH=255 class="textfield" />
</td>
</tr>
<tr>
<td align="center">
Lien Utorrent
</td>
<td>
<input type="text" name="txtUtorrent" id="txtUtorrent" value="<?php echo $film['lien_torrent']; ?>" size="40" MAXLENGTH=255 class="textfield" />
</td>
</tr>
<tr>
<td align="center">
Votre Pseudo
</td>
<td>
<input type="text" name="txtPeople" id="txtPeople" value="<?php echo $film['people']; ?>" size="20" class="textfield" />
</td>
</tr>
<tr>
<td align="center">
language</span>
</td>
<td>
<SELECT name="cboLanguage" id="cboLanguage" size="1">
<OPTION>VF
<OPTION>VO
<OPTION>VOST
</SELECT>
</td>
</tr>
<tr>
<td align="center">
Genre
</td>
<td>
<div style="overflow:scroll; height:100px; overflow-x:hidden; -webkit-border-top-left-radius: 40px; background:#EBEBEB;
-webkit-border-top-right-radius: 8px;-webkit-border-bottom-right-radius: 10px;-webkit-border-bottom-left-radius: 40px;-moz-border-radius-topleft: 40px;-moz-border-radius-topright: 8px;-moz-border-radius-bottomright: 10px;-moz-border-radius-bottomleft: 40px;border-top-left-radius: 40px;border-top-right-radius: 8px;border-bottom-right-radius: 10px;border-bottom-left-radius: 40px; width:300px;">
<ul>
<li><input type="checkbox" name="rbtnGenre" value="COMEDIE " />COMEDIE</li>
<li><input type="checkbox" name="rbtnGenre" value="AMOUR" />AMOUR</li>
<li><input type="checkbox" name="rbtnGenre" value="DRAMES " />DRAMES</li>
<li><input type="checkbox" name="rbtnGenre" value="HORREUR " />HORREUR</li>
<li><input type="checkbox" name="rbtngenre" value="SCIENCE-FICTION" />SCIENCE-FICTION</li>
<li><input type="checkbox" name="rbtnGenre" value="ACTION " />ACTION</li>
<li><input type="checkbox" name="rbtnGenre" value="HISTOIRE " />HISTOIRE</li>
<li><input type="checkbox" name="rbtnGenre" value="ANIMATION " />ANIMATION</li>
<li><input type="checkbox" name="rbtnGenre" value="DOCUMENTAIRE " />DOCUMENTAIRE</li>
<li><input type="checkbox" name="rbtnGenre" value="POLICIER " />POLICIER</li>
<li><input type="checkbox" name="rbtnGenre" value="SPORTS " />SPORTS</li>
<li><input type="checkbox" name="rbtnGenre" value="MUSIQUE " />MUSIQUE</li>
</ul>
</div>
</td>
</tr>
<tr>
<td align="center">
Qualité
</td>
<td>
<input type="checkbox" name="rbtnQual" value="HD" />HD
<input type="checkbox" name="rbtnQual" value="Tres bonne " />Tres bonne
<input type="checkbox" name="rbtnQual" value="Bonne " />Bonne
<input type="checkbox" name="rbtnQual" value="Moyenne " />Moyenne
<input type="checkbox" name="rbtnQual" value="Mauvaise " />Mauvaise
</td>
</tr>
</tbody></table><br /><br />
<p><h3><input type="submit" value="Envoyer le film" class="pane-list" name="inserer"/></p></h3><br>
<br>
<p><input type="submit" value="Modifier le film" name="modifier"></p>
</form>
</div>
<?php endforeach ?> |
Et voici ...
Donc en éspérant que quelqu'un saura me répondre, m'indiquer mon erreur, ou tout simplement, si quelqu'un peut me donner son avis, ce serait génial.
Merci.
L.