Salut,
"images/".$data[image] : chemin correct
par contre, keika effectivement ma requête ne passait pas… j'obtenais : Erreur SQL !
SELECT * From news WHERE id='2'
j'ai rajouté la connexion directement dans la fonction
require ("../private/connexion.php");
et là tout fonctionne ;-)
mon code à jour
<html>
<head>
<style type="text/css">
<!--
body {
background-color: #E5E5E5;
}
body,td,th {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #000000;
}
-->
</style>
</head>
<body>
<?php
echo $_POST[numero]."<br><br>";
echo $_POST[parution]."<br><br>";
echo nl2br(stripslashes($_POST[contenu]))."<br><br>";
include ("../private/connexion.php");
function CopiePhoto() {
if($_FILES[image][size]>1) {
copy($_FILES[image][tmp_name], "images/".$_FILES[image][name]);
}// if
}
function SupprimerPhoto($id) {
require ("../private/connexion.php");
$requete = "SELECT * From news WHERE id='$_GET[id]'";
$resultat = mysql_query ($requete, $connexion) or die('Erreur SQL !<br />'.$requete.'<br />'.mysql_error());
while ($data = mysql_fetch_array ($resultat)) {
unlink ("images/".$data[image]);
}
}
include ("miseEnForme.php");
if($_GET[action] == "delete") {
$supprimer = "DELETE FROM news WHERE id=$_GET[id]";
mysql_query ($supprimer, $connexion);
}
elseif ($_GET[action]=="update") {
CopiePhoto();
$modifier = "UPDATE news SET id='$_GET[id]', numero='$_POST[numero]', parution='$_POST[parution]', contenu='$_POST[contenu]', image='".$_FILES[image][name]."' WHERE id='$_GET[id]'";
mysql_query ($modifier, $connexion);
}
elseif ($_GET[action]=="insert") {
CopiePhoto();
$ajouter = "INSERT news SET id='', numero='$_POST[numero]', parution='$_POST[parution]', contenu='$_POST[contenu]', image='".$_FILES[image][name]."'";
mysql_query ($ajouter, $connexion);
}
elseif ($_GET[action] == "deletePhoto") {
SupprimerPhoto($id);
}
$requete = "SELECT * From news order by id DESC";
$resultat = mysql_query ($requete, $connexion);
?>
<table border=1 width=600>
<?
while ($data = mysql_fetch_row ($resultat)) {
list ($id, $numero, $parution, $contenu, $image) = $data;
echo "<tr><td valign='top' width='325' border='1'>";
echo "<h3>".$numero.' - '.$parution."</h3>";
echo resumeTexte($contenu)."<br><br>";
echo "</td><td valign='center' width='200'>";
echo "<div align='center'><img src='images/".$image."' width='140' height='200'></div><br>";
echo "</td><td valign='top' width='25'>";
echo "<a href='news_exe.php?id=$id&action=delete' onclick='return confirm (\"Supprimer cet enregistrement ?\");'><img src='images/supprimer.gif'></a>";
echo "</td><td valign='top' width='25'>";
echo "<a href='form_news.php?id=$id&action=update'><img src='images/modifier.gif'></a>";
echo "</td><td valign='top' width='25'>";
echo "<a href='news_exe.php?id=$id&action=deletePhoto'>Supprimer la photo</a>";
echo "</td></tr>";
}
?>
</td><td><a href='form_news.php?action=insert'><img src='images/ajouter.gif'></a></td></tr>
</table>
</body>
</html>