Hello, im trying to build a script that gets the date of an old row and select an ID number from it and then it would remove any rows the = that ID number, here is my code so far
it selects all of the id numbers but I can't get it to clear them, what is wrong?
Thanks
3dhomejoe
<?php
$con = mysql_connect('10.0.1.65','3dhomejoe','PASSWORDGOESHERE!!!!');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("eq2", $con);
$result = mysql_query("SELECT encid FROM encounter_table where starttime < DATE_SUB(CURDATE(),INTERVAL 30 DAY)");
if(!$result) {
$err=mysql_error();
print $err;
exit();
}
if(mysql_affected_rows()==0){
print "Nothing to do.";
} else {
while($row = mysql_fetch_array($result))
{
echo "Clearing";
mysql_query(DELETE FROM 'attacktype_table' WHERE ('encid'='$row[0]'));
}
}
mysql_close($con);
?>