-2

I have a database that opens images that I have in a folder. I can delete the entry from the database but not the image. The path of the image in the database contains backslash, but the path of the folder to be deleted has slash. I need to change the backslash to slash.

The database path is: fotos\mural\foto.jpg

The folder I want to delete is: ../../fotos/mural/foto.jpg

This is my scripy that does NOT work.

<?php
$v1 = $_GET['identifica'];
            $link = mysqli_connect("x.mysql.db", "x", "x");
            $database = mysqli_select_db($link, "xbecedqkxbisbe");   
            mysqli_set_charset( $link, "utf8");           
            $string = "SELECT * FROM mural WHERE id= $v1";
            $resultat = mysqli_query($link, $string);    
            while ($fila = mysqli_fetch_assoc($resultat)) { 
                $borra = $fila['Fotomural'];
                $direc = '(..\..\)';
                $ara = "'$direc''$borra'";
                unlink($ara);
        }   
            $query = "delete from mural where id = '$v1'";
            mysqli_query($link, $query);        
    ?>
Martijn
  • 15,791
  • 4
  • 36
  • 68

1 Answers1

0

You are wrapping these variables inside single quotes while concatenating.

$ara = "'$direc''$borra'";

Instead do this:

$Ara = "$direc$borra";
Tushar
  • 665
  • 5
  • 11