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
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");

 

 

 

Link to comment
Share on other sites

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!!!!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.