par
Chile » 30 mars 2006, 22:19
Bonsoir,
J'ai un petit pb de supression fichier via un formulaire. J'ai pourtant suivi les exemples trouvé dans le forum
j'ai une page qui me liste des "produits" avec pour chacun une photo.
J'ai pour chacun aussi la poss de supprimer l'enregistrement et la photo, via une page supression avec son id.
L'enregistrement est bien supprimé mais pas la photo

.
et j'ai ce message d'erreur :
Code : Tout sélectionner
Warning: unlink(images/): Is a directory in /home/horizo/www/exemple/suppays.php on line 5
voici le code de ma page suppression :
<?php require_once('../Connections/pays.php'); ?>
<?php
$photo = $row_suppr_fichier['photo'];
$sup = "images/".$photo;
unlink($sup);
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
if ((isset($_GET['id'])) && ($_GET['id'] != "")) {
$deleteSQL = sprintf("DELETE FROM bpays WHERE id=%s",
GetSQLValueString($_GET['id'], "int"));
mysql_select_db($database_pays, $pays);
$Result1 = mysql_query($deleteSQL, $pays) or die(mysql_error());
$deleteGoTo = "affichageimag.php";
if (isset($_SERVER['QUERY_STRING'])) {
$deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
$deleteGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $deleteGoTo));
}
$colname_suppr_fichier = "1";
if (isset($_GET['id'])) {
$colname_suppr_fichier = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
}
mysql_select_db($database_pays, $pays);
$query_suppr_fichier = sprintf("SELECT * FROM bpays WHERE id = %s", $colname_suppr_fichier);
$suppr_fichier = mysql_query($query_suppr_fichier, $pays) or die(mysql_error());
$row_suppr_fichier = mysql_fetch_assoc($suppr_fichier);
$totalRows_suppr_fichier = mysql_num_rows($suppr_fichier);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Document sans titre</title>
</head>
<body>
<div align="center"></div>
</body>
</html>
<?php
mysql_free_result($suppr_fichier);
?>
merci pour votre aide

Bonsoir,
J'ai un petit pb de supression fichier via un formulaire. J'ai pourtant suivi les exemples trouvé dans le forum :?
j'ai une page qui me liste des "produits" avec pour chacun une photo.
J'ai pour chacun aussi la poss de supprimer l'enregistrement et la photo, via une page supression avec son id.
L'enregistrement est bien supprimé mais pas la photo :cry: .
et j'ai ce message d'erreur :
[code]Warning: unlink(images/): Is a directory in /home/horizo/www/exemple/suppays.php on line 5[/code]
voici le code de ma page suppression :
[php]<?php require_once('../Connections/pays.php'); ?>
<?php
$photo = $row_suppr_fichier['photo'];
$sup = "images/".$photo;
unlink($sup);
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
if ((isset($_GET['id'])) && ($_GET['id'] != "")) {
$deleteSQL = sprintf("DELETE FROM bpays WHERE id=%s",
GetSQLValueString($_GET['id'], "int"));
mysql_select_db($database_pays, $pays);
$Result1 = mysql_query($deleteSQL, $pays) or die(mysql_error());
$deleteGoTo = "affichageimag.php";
if (isset($_SERVER['QUERY_STRING'])) {
$deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
$deleteGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $deleteGoTo));
}
$colname_suppr_fichier = "1";
if (isset($_GET['id'])) {
$colname_suppr_fichier = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
}
mysql_select_db($database_pays, $pays);
$query_suppr_fichier = sprintf("SELECT * FROM bpays WHERE id = %s", $colname_suppr_fichier);
$suppr_fichier = mysql_query($query_suppr_fichier, $pays) or die(mysql_error());
$row_suppr_fichier = mysql_fetch_assoc($suppr_fichier);
$totalRows_suppr_fichier = mysql_num_rows($suppr_fichier);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Document sans titre</title>
</head>
<body>
<div align="center"></div>
</body>
</html>
<?php
mysql_free_result($suppr_fichier);
?>[/php]
merci pour votre aide :wink: