but it looks like you didnt fetch it when you are asking it to delete all those that use the same directories
msql = $conn->prepare("DELETE FROM uploads WHERE Directory = ?");
but it looks like you didnt fetch it when you are asking it to delete all those that use the same directories
msql = $conn->prepare("DELETE FROM uploads WHERE Directory = ?");
Oh i see. so can you give me an example of the corrected code?
[php]
if (isset($_POST[“delete”]))
{
$file = $result [“Directory”];
unlink(“uploads/” . $file);
$msql = $conn->prepare(“DELETE FROM uploads WHERE Directory = ?”);
while ($result = $sql -> fetch())
{
$msql->execute(array($file));
$msql->execute();
}
}
[/php]
doin best i can w/pdo but along that lines
Your code worked until it wont delete the first result. But wait i found an alternative…
What if i was supposed to submit the delete button to a file called delete.php with the delete and unlink()
script on it. and instead of messing arround with fetching and exporting the $result [“Directory”],
we simple transported the path with the $_GET method in the address bar? then in the delete/unlink script (delete.php) we can just $_GET it from the address bar. correct? then once it deletes everything, it header()
redirects to the profile/gallery page. correct?
are you only deleting one or many form the same directory
because a while loop should find all that have the where clause
everything is in the uploads folder. but do you like the alternative?
Wait whaT?
ok so you have your session id for the user and if he wants to delete that picture if it is his he can and when he does he can only delete that picture from that button right
does the picture have a unigue id for it
you can call that in your where clause when it looks for what to delete
Correct. The if statements make sure the userid is his and that he is logged on before displaying the button.
The button leads hime to the script page, which $_GET the filename (the directory) from the address bar
and delete and unlink from there. so it all comes from the address bar instead of doing what we were doing before. simpler i think, right?
yes you can do that but i mean unique id as in not the session userid but the id of the picture and you can use that in your where clause if your code doesnt work
The pics dont have id’s though.
wouldnt it be easier if you gave them unique id’s
explain how please
like this i showed but with your pdo
not tested like i said
i am out will be able to help yo better tomorrow