Jump to content

Recommended Posts

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'");
}

Link to comment
https://forums.phpfreaks.com/topic/56258-solved-unban-script/
Share on other sites

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!

 

Link to comment
https://forums.phpfreaks.com/topic/56258-solved-unban-script/#findComment-277895
Share on other sites

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]

Link to comment
https://forums.phpfreaks.com/topic/56258-solved-unban-script/#findComment-278386
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/56258-solved-unban-script/#findComment-278475
Share on other sites

got it working! :D

 

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'");
}

Link to comment
https://forums.phpfreaks.com/topic/56258-solved-unban-script/#findComment-278598
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.