Im making an admin panel and when I try to delete a news post I hit the delete link and it should go through it all ok, and it does in sense. It shows no error, but it always says: You must have made a mistake in using this page. Do you see anything in there that is causing it to not get the id?
<?php
ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);
if ($dbc = @mysql_connect ('localhost', 'root', '')) {
if (!@mysql_select_db ('news')) {
die ('Could not select the database because: <b>' . mysql_error() . '</b>');
}
} else {
die ('Could not connect to MySQLbecause: <b>' . mysql_error() . '</b>');
}
if (isset ($_POST['submit'])) {
//Define the query
$query = "DELETE FROM news_entries WHERE news_id={$_GET['id']}";
$r = mysql_query ($query); // Execute the query.
//Report result
if (mysql_affected_rows() == 1) {
print '<p>The Blog Entry Was Deleted</p>';
} else {
print "<p>Could not delete the entry because: <b>" . mysql_error() . "</b>. The query was $query.</p>";
}
} else {
//Display the entry in a form
if (is_numeric ($_GET['id'])) {
//Define the query.
$query = "SELECT * FROM news_entries WHERE news_id={$_GET['id']}";
if ($r == mysql_query ($query)) {
$row = mysql_fetch_array ($r);
//Make the form
print '<form action="deleteentry.php" method="post">
<p>Are you sure you want to delete this entry?</p>
<p><h3>' . $row['title'] . '</h3>' . $row['entry'] . '<br />
<input type="hidden" name="id" value="' . $_GET['id'] . '" />
<input type="submit" name=submit" value="Delete this entry." /></p>
</form>';
} else {
print "<p>Could not retrieve the entry because: <b>" . mysql_error() . "</b>.";
}
} else { // No Id Set
print '<p><b>You must have made a mistake in using this page.</b></p>';
}
} // End main IF
mysql_close();
?>