Here's the code:
<?php
$file = file('../posts.php');
$display = $_POST['oldpost'];
$display2 = ("$display+1");
for($x=$display;$x<$display2;$x++) {
echo "$file[$x]";
$oldpost = "$file[$x]";
}
$fp = fopen("../posts.php", 'w+');
$new = str_replace("$oldpost","","$oldpost");
fwrite($fp, $new);
fclose($fp);
?>
Now, I WANT it to delete the old post (which has it's ID sent from admin.php).
Example, if I wanted to delete the post on the first line of posts.php I would put 1. Why does this wipe out the entire posts.php file when I run it?