Page 1 of 1

Problem with My Script

Posted: Fri Oct 24, 2008 11:12 am
by factoring2117
Hello everyone,

I am been kicking myself for the last 24 hours with the problem. I decided to come on here and ask for help.

I have a set of users who pay to be on a list for a certain amount of time. I would like my script to delete the user from the list when the current $date is > the $expire_date. For some reason I cannot get this to work. Here is my code thus far.

Code: Select all

<?php
   $date = date("Y-m-d H:i:s");
   $res = mysql_query("SELECT id, myspaceid, nick, image, expire_time FROM `vip` WHERE game = $game_no order by id asc");
   while($associate = mysql_fetch_array($res)) {
      
      $id = $associate['id'];
      $expire_time = $associate['expire_time'];
   if($date > $expire_time) {
      $delete = mysql_query("DELETE FROM `vip` WHERE `expire_time` = $expire_time");
      } else {
 
   
   
?>
            <center>
               <table cellspacing="18" cellpadding="0" border="0">
               <?php
   
                  $i =0;
 
                  if(mysql_num_rows($r) > 0)
                  {
                     echo '<tr>';
                     while($row = mysql_fetch_array($res))
                     {
                        if($i % $image_per_row2 == 0)
                        {
                           echo '</tr>';
                           echo '<tr>';
                        
                        }
      
                        $img_src = $row['image'];
                        $myspaceid = $row['myspaceid'];
                        $title = $row['nick'];
      
                        echo '<td align="center"><a target="_blank" rel="nofollow"  href="http://collect.myspace.com/index.cfm?fuseaction=invite.addfriend_verify&friendID='.$myspaceid.'" title="'.$title.'"><img src="'. $img_src .'" height="75" width="75" border="0"></a></td>';
 
                        $i++;   
         
                     }
      ?>
                        <td>   <form action="/featured/index.php" method="POST">
<input type="hidden" name="game" value="<?php echo "$game" ?>" />
<input type="hidden" name="amount" value="<?php echo "$amount" ?>" />
<input type="hidden" name="amount2" value="<?php echo "$amount2" ?>" />
<input type="hidden" name="amount3" value="<?php echo "$amount3" ?>" />
<input type="hidden" name="time" value="<?php echo "$time" ?>" />
<input type="hidden" name="time2" value="<?php echo "$time2" ?>" />
<input type="hidden" name="time3" value="<?php echo "$time3" ?>" />
<input type="hidden" name="invites" value="<?php echo "$invites" ?>" />
<input type="hidden" name="invites2" value="<?php echo "$invites2" ?>" />
<input type="hidden" name="invites3" value="<?php echo "$invites3" ?>" />
<input type="hidden" name="item_name" value="<?php echo "$item_name" ?>" />
<input type="hidden" name="item_name2" value="<?php echo "$item_name2" ?>" />
<input type="hidden" name="item_name3" value="<?php echo "$item_name3" ?>" />
<input type="image" src="http://www.spuko.com/images/no_pic.gif" border="0" name="submit" alt="" />
</form></td>
<?php
                     echo '</tr>';
                  }
                  else 
                  {
                     //message to come up in case of empty list for a game.
                     echo '<tr><td align="center">NO CREW IN THIS GAME</td></tr>';
                  }
                  }
                  }
               ?>
                   
               </table>
                   
            </center>
Please let me know if you need any other info.

Thanks

Re: Problem with My Script

Posted: Fri Oct 24, 2008 12:12 pm
by requinix
Why not just

Code: Select all

DELETE FROM `vip` WHERE `expire_time` < NOW()
Run it once to take care of everyone.