код обновлен!! Я пытаюсь удалить изображение из определенной папки + данные из базы данных. до сих пор он удаляет данные базы данных, однако это не отменяет связь изображения вместе с данными базы данных... фрагмент сценария следующим образом:
// echo '<pre>'; var_dump($row_rs_galleries);exit;
$path=$_get[$row_rs_galleries['gallery_image']];
$file="../uploads/gallerytitle/resized/$path";
unlink($file);
$deleteSQL = sprintf("DELETE FROM galleries WHERE gallery_id=%s",
GetSQLValueString($_GET['gid'], "int"));
повторяя массив, он показывает:
array(4) {
["gallery_id"]=>
string(2) "20"
["gallery_name"]=>
string(9) "sdvsdvsdv"
["gallery_image"]=>
string(27) "resized_140959609221730.JPG"
["image_alt"]=>
string(8) "dsvsdvsd"
}
Он удаляет данные из базы данных, но по-прежнему не отменяет связь с изображением ... Путь вроде в порядке, массив тоже. В чем может быть проблема?
Весь код страницы здесь (на случай, если я поместил функцию отмены связи не в то место?)
<?php require_once('../Connections/conn_hell.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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;
}
}
$colname_rs_galleries = "-1";
if (isset($_GET['gid'])) {
$colname_rs_galleries = $_GET['gid'];
}
mysql_select_db($database_conn_hell, $conn_hell);
$query_rs_galleries = sprintf("SELECT * FROM galleries WHERE gallery_id = %s", GetSQLValueString($colname_rs_galleries, "int"));
$rs_galleries = mysql_query($query_rs_galleries, $conn_hell) or die(mysql_error());
$row_rs_galleries = mysql_fetch_assoc($rs_galleries);
$totalRows_rs_galleries = mysql_num_rows($rs_galleries);
if ((isset($_GET['gid'])) && ($_GET['gid'] != "")) {
//--------------------------The unlink----------------------------------------------------------
//echo '<pre>'; var_dump($row_rs_galleries);exit;
$path=$_GET[$row_rs_galleries['gallery_image']];
$file= realpath(__DIR__ . "../uploads/gallerytitle/resized/$path");
unlink($file);
//-----------------------------------------------End unlink
$deleteSQL = sprintf("DELETE FROM galleries WHERE gallery_id=%s",
GetSQLValueString($_GET['gid'], "int"));
mysql_select_db($database_conn_hell, $conn_hell);
$Result1 = mysql_query($deleteSQL, $conn_hell) or die(mysql_error());
$deleteGoTo = "../announcments.php?aid=5";
if (isset($_SERVER['QUERY_STRING'])) {
$deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
$deleteGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $deleteGoTo));
}
?>
<?php
mysql_free_result($rs_galleries);
?>