Jump to content

Problem with Deleting an ID# according to expire time


factoring2117

Recommended Posts

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.

 

<?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 anymore info. Thanks for your help.

You can't compare strings of dates. You need to convert them into time stamps.

 

Try this:

 

<?php

   $date = time();
   $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 > strtotime($expire_time)) {
      $delete = mysql_query("DELETE FROM `vip` WHERE `expire_time` = $expire_time");
      } else {

?>

 

 

Orio.

Archived

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

×
×
  • 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.