Hi Brad,
I have changed the way I am processing the data.
I created a new feild in the data table named "deleteTime", When records are updated if they have a status code of "2" or "5" the current datetime plus 1 hour is written to that feild.
if($Stat == 2 || $Stat == 5){
$updateSQL = sprintf("UPDATE flightdata SET DeleteTime=%s WHERE AODBUniqueID=%s",
GetSQLValueString($_POST['DeleteTime'] = $deleteTime = date("Y-m-d H:i:s", strtotime ("+1 hour")), "date"),
GetSQLValueString($_POST['AODBUniqueID'] = $AODBUniqueID, "text"));
mysql_select_db($database_flightq, $flightq);
$Result1 = mysql_query($updateSQL, $flightq) or die(mysql_error());
}
At the end of the script I have the code below which deletes all records that match:
mysql_select_db($database_flightq, $flightq);
$query_deleteflights = mysql_query("DELETE FROM flightdata WHERE CURRENT_TIMESTAMP > DeleteTime");
$flights = mysql_query($query_deleteflights, $flightq) or die(mysql_error());
$row_flights = mysql_fetch_assoc($flights);
$totalRows_flights = mysql_num_rows($flights);
print "Flight records deleted: " .$totalRows_flights;
But I do get an error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1' at line 1.
for the life of me I can't see whats causing the error but the record deletion works.
Any ideas as to why the error is triggered.
Many thanks for any time you spend looking at this.