I need the code delete all the records from the table that contain a certain date. I wrote the following code but it doesn't work. If anybody would be so kind to assist me into fixing it I would be forever thankfull.
<?php
//do not reply on the button being pressed
$month= (!empty($_POST['month']) ? $_POST['month']) : '');
//only execute when month has a value
//should also think about validating the string so it is proper format
if (!empty($month))
{
//should always use mysql_error() for accurate reports
$connection = mysql_connect("localhost", "***", "****") or die(mysql_error());
//should always use mysql_error() for accurate reports
mysql_select_db("*****",$connection) or die (mysql_error());
//you were trying to execute the query twice, or something
//should have error reporting on ALL queries
//good habbit of escaping variables -- easier to read
$deleteresult = mysql_query("DELETE FROM `auth` WHERE month = '".$month."'") or die(mysql_error());
//not really sure why you need $affected_rows.. it has no apparent purpose here
$affected_rows = mysql_affected_rows($deleteresult,$connection);
echo "<b>Check</b> was executed.";
}
?>
You had some weird stuff going on in your snipplet, this is the cleaned up version.