mysql_fetch_array() Récupération de données
Bonjour,
j'essaye de dev un blog. Pour ma page d'édition des articles, j'ai un soucis pour récupérer les données de l'article choisi et les afficher dans l’éditeur.
mon code:
D'abord un bout de ma page ou se trouve le bouton éditer.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| <?php
while ($row = mysql_fetch_array($article)){
?>
<tr class="articleList">
<td>
<a href="edit.php?id='.article["id"].'">Edit</a>
</td>
<td class="numero">
<?php echo $row['id'] ; ?>
</td>
<td class="titre">
<?php echo $row['titre']; ?>
</td>
<td class="description">
<?php echo $row['description'] ; ?>
</td>
<td class="date">
<?php echo $row['date'] ; ?>
</td> |
ensuite le code php de ma page edit :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
mysql_select_db('blog', $con);
$id= $_GET['id'];
$result = mysql_query("SELECT 'titre', 'description', 'article' FROM article WHERE id = '$id'");
$data = mysql_fetch_array($result) or die(mysql_error());
$titre = $data['titre'];
$description = $data['description'];
$article = $data['article'];
?> |
et enfin le code html qui affiche les champs :
Code:
1 2 3 4 5 6 7 8 9 10 11 12
| <table>
<tr>
<td class="topedit"><input name="titre" type="text" size="30" value="<?php echo htmlspecialchars($titre); ?>">
</input><input name="description" type="text" size="120" value="<?php echo htmlspecialchars($description); ?>"></input> </td>
</tr>
<tr>
<td class="inputedit">
<textarea name="article" class="inputtext" type="text" value="<?php echo htmlspecialchars($article); ?>"></textarea>
</td>
</tr>
</table> |
et donc je reçoit l'erreur :
Citation:
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\Equablog\edit.php on line 16
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 '.article['id'].''' at line 1
la ligne 16 correspond à
Code:
$data = mysql_fetch_array($result) or die(mysql_error());
Voilà je ne comprend pas trop... Un soucis dans le code directement ou un soucis à cause des " et ' ?
Merci d'avance !