xyn Posted July 27, 2007 Share Posted July 27, 2007 Hey. I'm having a small problem with my sql syntax. Basically I wanted to check how many e-mails a member is allowed to send out. then using sql num rows to see how many they have sent. Well i used date("j/m/y, h:i:s", strtotime("today")); and i don't think this is the correct method. my code: while(list($max_mail, $max_tmout) = mysql_fetch_array($sql_limit_perm)) { $email_maximum = $max_mail; $email_timeout = $max_tmout; switch($email_maximum) { case x: $ignore_mail_max = 1; break; default: $ignore_mail_max = 0; break; } } if($ignore_mail_max != "1") { $sql_senders_limit = mysql_query("SELECT `id` FROM `asc_emaillogs` WHERE `sentby`='".$_SESSION['userName']."' AND `senton`='".date("j/m/Y, H:i:s", strtotime("Today"))."'"); if(mysql_num_rows($sql_senders_limit) >=$email_maximum) { $error[] = "You have reached your limit today."; } } the ignroe is for mods, super-mods, admins and super-admins thanks, ash Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 27, 2007 Share Posted July 27, 2007 I would suspect this is just a simple issue to do with how you are storing the date the email was sent on. What field type are you using to store this? If you are using a datetime field, then you are going to need to select all of those dates and times which are between the beginning of the start of the current day, and the current time. If you are using a date field, then you'll just need a simple match on the date. If either of these are the case, take a look at the way the dates are actually stored. They are stored as yyyy-mm-dd. You'll need to format your date in this way too. Finally, if you are storing your date in a varchar field(bad idea) then you can use the mysql function UNIX_TIMESTAMP to compare with a php generated timestamp for the current day. Quote Link to comment 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.