twilitegxa Posted July 6, 2011 Share Posted July 6, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/241170-two-unlink-functions/ Share on other sites More sharing options...
gizmola Posted July 6, 2011 Share Posted July 6, 2011 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"); Quote Link to comment https://forums.phpfreaks.com/topic/241170-two-unlink-functions/#findComment-1238774 Share on other sites More sharing options...
twilitegxa Posted July 6, 2011 Author Share Posted July 6, 2011 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!!!! Quote Link to comment https://forums.phpfreaks.com/topic/241170-two-unlink-functions/#findComment-1238777 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.