Jump to content

Archived

This topic is now archived and is closed to further replies.

Gingechilla

DELETE FROM userinfo WHERE ID = 0 OR 4 << Something like this - could it work?

Recommended Posts

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)

Share this post


Link to post
Share on other sites
[!--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]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.