Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 33

Thread: Send Me An Email Of Birthdays

  1. #11
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Actually the other post will answer your question too http://www.dynamicdrive.com/forums/s...t=18497&page=2

  2. #12
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Just came to mind, but did you change the following parts in red?

    Code:
    $results = mysql_query("SELECT * FROM `table` WHERE `birthday` LIKE '$year-$month%'");
    and

    Code:
    while ($qry = mysql_fetch_array($results)) {
          if (strtotime($qry['birthday']) <= (time() + 86400*14)) {
             $bdays[] = Array($qry['Name'] => $qry['birthday']);
          }
      }
    Other than that (that is, if you did change those items above), the script should work.

    Hope this helps
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #13
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hmmm yea I did change those bits, but now when I ran it the top line of this is producing a "Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource"

    PHP Code:
    if (mysql_num_rows($results) < 1) {
    die(
    'There are no members with birthdays this month');
    }

    else {

    $bdays = Array();

      while (
    $qry mysql_fetch_array($results)) {
          if (
    strtotime($qry['DateOfBirth']) <= (time() + 86400*14)) {
            
    $bdays[] = Array($qry['FirstName'] => $qry['DateOfBirth']);
          }
      } 

  4. #14
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Well then it is something in this part of the code.

    Code:
    $results = mysql_query("SELECT * FROM `table` WHERE `birthday` LIKE '$year-$month&#37;'");
    or, did you make sure to make the mysql connection and select the database? If not, then that would be the cause of the error.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  5. #15
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok I got it to email me... But the formatting is all wrong, first to get it to send anything through I query
    PHP Code:
    LIKE '%$month%'" 
    , and I recieve an email but it look slike this
    Below is a list of the members and their birthdays that are coming up in the next couple of weeks. \r\nThe birthdays are as follows: \r\n-----------------------------------------\r\n\r\nName (Birthday): 0 (Array) \r\nName (Birthday): 1 (Array) \r\nName (Birthday): 2 (Array) \r\nName (Birthday): 3 (Array) \r\nName (Birthday): 4 (Array) \r\nName (Birthday): 5 (Array) \r\nName (Birthday): 6 (Array) \r\nName (Birthday): 7 (Array) \r\nName (Birthday): 8 (Array) \r\nName (Birthday): 9 (Array) \r\nName (Birthday): 10 (Array) \r\nName (Birthday): 11 (Array) \r\nName (Birthday): 12 (Array) \r\nName (Birthday): 13 (Array) \r\nName (Birthday): 14 (Array) \r\nName (Birthday): 15 (Array) \r\nName (Birthday): 16 (Array) \r\nName (Birthday): 17 (Array) \r\nName (Birthday): 18 (Array) \r\nName (Birthday): 19 (Array) \r\nName (Birthday): 20 (Array) \r\nName (Birthday): 21 (Array)
    Any ideas on this one?

  6. #16
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hiya any ideas why the email is doing the above? I got so close!

  7. #17
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Sorry, didn't see that you posted anything since my last post. Anyways, I was looking it over and I though of a somewhat better way to do this. Take a look at the following code:

    Code:
    <?php
    $to = "me@mydomain.com"; //your email address
    $subject = "Member's birthdays"; //subject of email
    
    include('dbconnect.php');
    $year = date('Y');
    $month = date('m');
    
    $results = mysql_query("SELECT * FROM `table` WHERE `birthday` LIKE '&#37;$month%'");
    
    if (mysql_num_rows($results) < 1) {
    die('There are no members with birthdays this month');
    }
    
    else {
    
      while ($qry = mysql_fetch_array($results)) {
          if (strtotime($qry['birthday']) <= (time() + 86400*14)) {
             $bdays .= 'Name: '.$qry['Name'].' ('.$qry['birthday'].') \r\n';
          }
      }
    
    $message = 'Below is a list of the members and their birthdays that are coming up in the next couple of weeks. \r\n';
    
    $message .= 'The birthdays are as follows: \r\n';
    $message .= '-----------------------------------------\r\n\r\n';
    $message .= $bdays;
    }
    
    $from = "From: PHP Script <noreply@mydomain.com";
    
    mail($to, $subject, $message, $from);
    }
    ?>
    That should take care of the formatting (in the email) part. If not, we may need to send some more header information in the email. Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  8. #18
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Actually I just had a thought, If I get the email every week or even every two weeks, the 14 day will make birthdays overlap, so I think I want to change it slighty if possible. I think what I'll do it make it email me on the 14th of every month, all the members who are having birthdays for the next month... Any idea how to do that?

  9. #19
    Join Date
    Jan 2006
    Location
    At home
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I am not sure.. how does it work but have a look at the codes of phpbb3 forum script. this script sends email automatically who have birthday in your database. If you have someidea about php you will understand the codings. i know it is bit difficult task but will yield you the result of your query for sure
    Regards

  10. #20
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok have it all up and running, it just does not like the
    PHP Code:
    r/n
    , it seems to display them in the message. I tried adding <br> tags but they also just displayed in the message...

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •