Jump to content

Two unlink functions?


twilitegxa

Recommended Posts

 

How do I add another unlink function to my code? Here is what I have:

 

 


<?php


$dbhost = 'localhost';
$dbuser = 'username';
$dbpass = 'password';


$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');


$dbname = 'database';
mysql_select_db($dbname);


$all_records = "SELECT * FROM gallery WHERE id='$_GET[id]'";
$all_records_res = mysql_query($all_records);


while($image=mysql_fetch_array($all_records_res)){
$location = $image['image'];
$location2 = $image['image2'];


}


//echo "[url=http://jhrevell.com/wp-content/themes/twentyten_3/upload/]http://jhrevell.com/wp-content/themes/twentyten_3/upload/[/url]" . $location;


unlink("upload/" . $location);


$query = "DELETE FROM gallery WHERE id='$_GET[id]'";
$query_res = mysql_query($query) or die(mysql_error());


header("Location: [url=http://jhrevell.com/manage]http://jhrevell.com/manage[/url]");


?>

 

 

I tried adding another statement like:

 

 

unlink("upload/" . $location2);

 

 

But I am getting an error, so there must be another way to do this. Can anyone tell me how? I even tried adding to the original statement, unlink("upload/" . $location . $location2); and I know that was wrong because it just made both filenames run into one. How do I do this?

Link to comment
https://forums.phpfreaks.com/topic/241170-two-unlink-functions/
Share on other sites

Adding a second unlink is exactly what you need.  What error are you getting?

 

Not that this is related, but this line of code is completely wrong:

 

header("Location: [url=http://jhrevell.com/manage]http://jhrevell.com/manage[/url]");

 

Should be something like:

 

header("Location:/manage");

 

 

 

LOL I just added the code back and altered what you mentioned, and now it's working! Maybe that was causing the error, because it was something about not being able to send the header because it was already started somewhere else. Thank you so much!!!!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.