[SQL] Problème de variable non définies
Bonjour , suite à une améliorations de mon script j'ai un message m'indiquant que trois variable ne sont pas définis .
Voila les code des deux fichiers en question :
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
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
<head>
<title>Rédiger une news</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
h3, form
{
text-align:center;
}
</style>
</head>
<body>
<h3><a href="liste_news.php">Retour à la liste des news</a></h3>
<?php
require('config.php');
if (isset($_GET['modifier_news']))
{
$retour = mysql_query('SELECT * FROM news WHERE id=' . $_GET['modifier_news']);
$donnees = mysql_fetch_array($retour);
$text = stripslashes($_POST['texte']);
$titre = $donnees['titre'];
$image = $donnees['image'];
$texte = $donnees['texte'];
$id_news = $donnees['id'];
}
else
{
$titre = '';
$image = '';
$mois = '';
$annee = '';
$texte = '';
$id_news = 0;
}
?>
<form action="liste_news.php" method="post">
<p>Titre : <input type="text" size="30" name="titre" value="<?php echo $titre; ?>" /></p>
<p>Image : <input type="text" size="50" name="image" value="<?php echo $image; ?>"/><p>
<p>Insere le mois
<label>
<select name="mois">
<option value="01">Janvier</option>
<option value="02">Fevrier</option>
<option value="03">Mars</option>
<option value="04">Avril</option>
<option value="05">Mai</option>
<option value="06">Juin</option>
<option value="07">Juillet</option>
<option value="08">Aout</option>
<option value="09">Septembre</option>
<option value="10">Octobre</option>
<option value="11">Novembre</option>
<option value="12">Décembre</option>
</select>
</label>
</p>
<p> Et l''année <label>
<select name="annee">
<option value="07">2007</option>
<option value="08">2008</option>
<option value="09">2009</option>
<option value="10">2010</option>
</select>
</label>
<br /></p>
Contenu :<br />
<textarea name="texte" cols="50" rows="10">
<?php echo $texte; ?>
</textarea><br />
<input type="hidden" name="id_news" value="<?php echo $id_news; ?>" />
<input type="submit" value="Envoyer" />
</p>
</form>
<p><a href=""></a></p>
</body>
</html> |
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
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
<head>
<title>Liste des news</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
h2, th, td
{
text-align:center;
}
table
{
border-collapse:collapse;
border:2px solid black;
margin:auto;
}
th, td
{
border:1px solid black;
}
</style>
</head>
<body>
<h2><a href="rediger_news.php">Ajouter une news</a></h2>
<?php
require('config.php');
if (isset($_POST['titre']) AND isset($_POST['texte']))
{
$titre = addslashes(htmlspecialchars(trim($_POST['titre'])));
$texte = addslashes(trim($_POST['texte']));
if ($_POST['id_news'] == 0)
{
mysql_query("INSERT INTO news VALUES('', '" . $titre . "' , '" . $texte . "' , '" . $image . "' , '" . $mois . "' , '" . $annee . "' , '" . time() . "')");
}
else
{
mysql_query("UPDATE news SET titre='" . $titre . "', texte='" . $texte . "' , image='" . $image . "' WHERE id=" . $_POST['id_news']);
}
}
if (isset($_GET['supprimer_news']))
{
mysql_query('DELETE FROM news WHERE id=' . $_GET['supprimer_news']);
}
?>
<table><tr>
<th>Modifier</th>
<th>Supprimer</th>
<th>Titre</th>
<th>Date</th>
</tr>
<?php
$retour = mysql_query('SELECT * FROM news ORDER BY id DESC');
while ($donnees = mysql_fetch_array($retour)) // On fait une boucle pour lister les news
{
?>
<tr>
<td><?php echo '<a href="rediger_news.php?modifier_news=' . $donnees['id'] . '">'; ?>Modifier</a></td>
<td><?php echo '<a href="liste_news.php?supprimer_news=' . $donnees['id'] . '">'; ?>Supprimer</a></td>
<td><?php echo stripslashes($donnees['titre']); ?></td>
<td><?php echo date('d/m/Y', $donnees['date']); ?></td>
</tr>
<?php
} // Fin de la boucle qui liste les news
?>
</table>
<p><a href="">Page d'accueil du site</a></p>
</body>
</html> |
Et voici le message en question
Citation:
Notice: Undefined variable: image in C:\Program Files\EasyPHP 2.0b1\www\News\liste_news.php on line 40
Notice: Undefined variable: mois in C:\Program Files\EasyPHP 2.0b1\www\News\liste_news.php on line 40
Notice: Undefined variable: annee in C:\Program Files\EasyPHP 2.0b1\www\News\liste_news.php on line 40
Merci d'avance