troubleshooting Question

MySQL Argument in Query - Before or Equal to current date

Avatar of Ryan Bayne
Ryan BayneFlag for United Kingdom of Great Britain and Northern Ireland asked on
SQL
2 Comments1 Solution1606 ViewsLast Modified:
Hey

I've never done this before. I'm trying to use an SQL query that has an argument. The aim is to retrieve all records from a table that holds a set of scheduled account deletions, where the scheduled date is equal to or before the current date.

Then delete those records. However so far nothing seems to happen. No records are deleted and no errors.

So how should I really be doing this?

Thanks all
elseif($service == "process")//Display form for creating new parent catagory
	{
		//get todays date
		$today = date("m.d.y"); 
 
		//Get data for accounts to be deleted
		$sql1 = mysql_query("SELECT * FROM deleteaccount WHERE delDATE <= '$today'");
		if (!$sql1)
		{
			die('Query execution problem getting accounts awaiting deletion: ' . mysql_error());
		}
		else
		{
			//put the found member ids for deletion into variable then delete their account
			while ($row = mysql_fetch_array($sql1, MYSQL_ASSOC))
			{	
				$owner = $row['delOWNER'];
				//delete the user entry with the id matching $owner
				$sql2 = mysql_query("DELETE FROM memb_userlist WHERE user_id = '$owner'");
				if (!$sql2) 
				{
					die('Query execution problem while deleting a members account: ' . mysql_error());
				}
				else
				{
					//remove the deletion entry from deleteaccount table
					$sql3 = mysql_query("DELETE FROM deleteaccount WHERE delOWNER = '$owner'");
				}
			}
			echo "<h3>All scheduled account have been deleted as requested</h3>";
		}
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros