Gingechilla Posted April 8, 2006 Share Posted April 8, 2006 I am trying to get something like this to work:[code] $sql = "DELETE FROM youritems WHERE User = 0 OR User = 4"; $sql2 = "DELETE FROM userinfo WHERE ID = 0 OR 4"; $result = mysql_query($sql); $result = mysql_query($sql2); echo "Accounts Reseted!";[/code]I want to delete accounts who have not been active for more than 200 days (via a strtotime), I put the above together to see if I could delete records with either the values in, however when the script is runs it deletes all of the records in the database, does anyone know how I can fix this?(I put 0 and 4 as a test, I hope to later replace it with a variable e.g. $userstodelete, and $userstodelete will push in some search results) Quote Link to comment Share on other sites More sharing options...
sasa Posted April 8, 2006 Share Posted April 8, 2006 [!--quoteo(post=362844:date=Apr 8 2006, 09:28 PM:name=Gingechilla)--][div class=\'quotetop\']QUOTE(Gingechilla @ Apr 8 2006, 09:28 PM) [snapback]362844[/snapback][/div][div class=\'quotemain\'][!--quotec--]I am trying to get something like this to work:[code] $sql = "DELETE FROM youritems WHERE User = 0 OR User = 4"; $sql2 = "DELETE FROM userinfo WHERE ID = 0 OR 4"; $result = mysql_query($sql); $result = mysql_query($sql2); echo "Accounts Reseted!";[/code]I want to delete accounts who have not been active for more than 200 days (via a strtotime), I put the above together to see if I could delete records with either the values in, however when the script is runs it deletes all of the records in the database, does anyone know how I can fix this?(I put 0 and 4 as a test, I hope to later replace it with a variable e.g. $userstodelete, and $userstodelete will push in some search results)[/quote]the logical expresion [code]ID = 0 OR 4[/code]is always true. It's same with exspresion [code](ID = 0) OR TRUE[/code]use[code]ID = 0 OR ID = 4[/code]or[code]ID in (1,4)[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.