lewis987 Posted June 19, 2007 Share Posted June 19, 2007 ok i have a script that if the banend <= than the current date then unban them but my problem is that it doesnt want to do it, any ideas? $datetime=date("y-m-d H:i:s"); $tblbanned=$prefix."banned"; if($datetime >= $rows['banend']){ mysql_query("UPDATE $tblbanned SET `banned` = '0' WHERE username='$user'"); } Quote Link to comment https://forums.phpfreaks.com/topic/56258-solved-unban-script/ Share on other sites More sharing options...
swoyercmk Posted June 19, 2007 Share Posted June 19, 2007 if($datetime >= $rows['banend']){ mysql_query("UPDATE $tblbanned SET `banned` = '0' WHERE username='$user'"); } I think your problem may be the highlighted typo. Unless I'm misunderstanding your structure, I do believe that should be 'banned' and not 'banend' Good luck! EDIT: oh wow, dee dee dee moment. I just reread this more carefully and realized you DID mean banend - as in Ban End. Apologies! I think the post below may be more on track. Good luck! Quote Link to comment https://forums.phpfreaks.com/topic/56258-solved-unban-script/#findComment-277895 Share on other sites More sharing options...
ToonMariner Posted June 19, 2007 Share Posted June 19, 2007 the query seems a bit odd to me try this <?php mysql_query("UPDATE $tblbanned SET `banned` = '0' WHERE `banneddate' < DATE_SUB(now(), 60 DAY)"); ?> Need mysql 4.1.1 for that I think. Quote Link to comment https://forums.phpfreaks.com/topic/56258-solved-unban-script/#findComment-277897 Share on other sites More sharing options...
lewis987 Posted June 19, 2007 Author Share Posted June 19, 2007 no luck with that either :S Quote Link to comment https://forums.phpfreaks.com/topic/56258-solved-unban-script/#findComment-277908 Share on other sites More sharing options...
lewis987 Posted June 20, 2007 Author Share Posted June 20, 2007 anyone? Quote Link to comment https://forums.phpfreaks.com/topic/56258-solved-unban-script/#findComment-278281 Share on other sites More sharing options...
lewis987 Posted June 20, 2007 Author Share Posted June 20, 2007 well? anyone got any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/56258-solved-unban-script/#findComment-278327 Share on other sites More sharing options...
AndyB Posted June 20, 2007 Share Posted June 20, 2007 Change: [code] if($datetime >= $rows['banend']){ mysql_query("UPDATE $tblbanned SET `banned` = '0' WHERE username='$user'"); } to: if($datetime >= $rows['banend']){ $query = "UPDATE $tblbanned SET `banned` = '0' WHERE username='$user'"; echo $query; // $result = mysql_query($query); } Does the query look like what you expected? Post the querystring here.[/code] Quote Link to comment https://forums.phpfreaks.com/topic/56258-solved-unban-script/#findComment-278386 Share on other sites More sharing options...
ToonMariner Posted June 20, 2007 Share Posted June 20, 2007 Andy - if there are 1000 users banned on one day then that loop will not unban them all (I say that as most pages are limited to 50 queries - which is why it would be more beneficial to just update those records where the banned date has expired as a block rather than individually). Lewis - what version of mysql are you running? <?php mysql_query("UPDATE $tblbanned SET `banned` = '0' WHERE `banneddate' < DATE_SUB(NOW(), 60 DAY)"); ?> That query should unban everyone who's ban date was more than 60 days ago. It does require that you store a banned date in the fields that is of a datetime type ('YYYY-MM-DD HH:mm:ss') if you have that then all should be fine. Quote Link to comment https://forums.phpfreaks.com/topic/56258-solved-unban-script/#findComment-278475 Share on other sites More sharing options...
lewis987 Posted June 20, 2007 Author Share Posted June 20, 2007 got it working! the code had to be: $banned = mysql_query("SELECT * FROM $tblbanned WHERE `username`='$user'"); $rows=mysql_fetch_array($banned); if($datetime > $rows['banend']){ mysql_query("UPDATE $tblbanned SET `banned` = '0' WHERE `username`='$user'"); } rather than: $banned = mysql_query("SELECT * FROM $tblbanned WHERE `username`='$user'"); $rows=mysql_fetch_array($banned); if($datetime >= $rows['banend']){ mysql_query("UPDATE $tblbanned SET `banned` = '0' WHERE `username`='$user'"); } Quote Link to comment https://forums.phpfreaks.com/topic/56258-solved-unban-script/#findComment-278598 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.