Ir para conteúdo
Fórum Script Brasil
  • 0

exclusão de imagem de pasta e dados do banco


XIM

Pergunta

Olá amigos,Boa noite,estou precisando de uma jauda de vocês,tenho um codigo aqui php,ele exclui na moral no banco de dado os dados referente a foto,mas não exclui a foto da pasta foto,não manjo bem php,se pudrem me ajudar agradeceria.

eis o codigo:

<?php include "topo.php";?>

<?php require_once('../Connections/conexao.php'); ?>

<?php

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['cod_prod'])) && ($_GET['cod_prod'] != "")) {

$deleteSQL = sprintf("DELETE FROM produtos WHERE cod_prod=%s",

GetSQLValueString($_GET['cod_prod'], "int"));

mysql_select_db($database_conexao, $conexao);

$Result1 = mysql_query($deleteSQL, $conexao) or die(mysql_error());

$deleteGoTo = "excluir_prod2.php";

if (isset($_SERVER['QUERY_STRING'])) {

$deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";

$deleteGoTo .= $_SERVER['QUERY_STRING'];

}

echo "<br>";

echo "<center><b>Operação realizada com sucesso!!!</b></center>";

}

?>

Link para o comentário
Compartilhar em outros sites

5 respostass a esta questão

Posts Recomendados

  • 0

Vo te passar o código pra você não atrasar seu projeto/estudo, mas não se esqueça de fazer o que o nosso amigo Eserra sugeriu.

<?php include "topo.php";?>
<?php require_once('../Connections/conexao.php'); ?>
<?php
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['cod_prod'])) && ($_GET['cod_prod'] != "")){
    $deleteSQL = sprintf("DELETE FROM produtos WHERE cod_prod=%s",GetSQLValueString($_GET['cod_prod'], "int"));
    
    mysql_select_db($database_conexao, $conexao);
    $Result1 = mysql_query($deleteSQL, $conexao) or die(mysql_error());
    #Você passa como parâmetro da função unlink o caminho da imagem. Por exemplo: C:/wamp/www/site/imagem/nomedaimagem.jpg
    unlink();
    
    $deleteGoTo = "excluir_prod2.php";
    if (isset($_SERVER['QUERY_STRING'])) {
        $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
        $deleteGoTo .= $_SERVER['QUERY_STRING'];
    }
    
    echo "<br>";
    echo "<center><b>Operação realizada com sucesso!!!</b></center>";
}
?>

Editado por dedas
Link para o comentário
Compartilhar em outros sites

  • 0
Vo te passar o código pra você não atrasar seu projeto/estudo, mas não se esqueça de fazer o que o nosso amigo Eserra sugeriu.

<?php include "topo.php";?>
<?php require_once('../Connections/conexao.php'); ?>
<?php
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['cod_prod'])) && ($_GET['cod_prod'] != "")){
    $deleteSQL = sprintf("DELETE FROM produtos WHERE cod_prod=%s",GetSQLValueString($_GET['cod_prod'], "int"));
    
    mysql_select_db($database_conexao, $conexao);
    $Result1 = mysql_query($deleteSQL, $conexao) or die(mysql_error());
    #Você passa como parâmetro da função unlink o caminho da imagem. Por exemplo: C:/wamp/www/site/imagem/nomedaimagem.jpg
    unlink();
    
    $deleteGoTo = "excluir_prod2.php";
    if (isset($_SERVER['QUERY_STRING'])) {
        $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
        $deleteGoTo .= $_SERVER['QUERY_STRING'];
    }
    
    echo "<br>";
    echo "<center><b>Operação realizada com sucesso!!!</b></center>";
}
?>

obrigado amigo,vou testar aqui,pode deixar farei oque o outro amigo orientou,forte abraço

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,2k
    • Posts
      652k
×
×
  • Criar Novo...