Actually the other post will answer your question too http://www.dynamicdrive.com/forums/s...t=18497&page=2![]()
Actually the other post will answer your question too http://www.dynamicdrive.com/forums/s...t=18497&page=2![]()
Just came to mind, but did you change the following parts in red?
andCode:$results = mysql_query("SELECT * FROM `table` WHERE `birthday` LIKE '$year-$month%'");
Other than that (that is, if you did change those items above), the script should work.Code:while ($qry = mysql_fetch_array($results)) { if (strtotime($qry['birthday']) <= (time() + 86400*14)) { $bdays[] = Array($qry['Name'] => $qry['birthday']); } }
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
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']);
}
}
Well then it is something in this part of the code.
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.Code:$results = mysql_query("SELECT * FROM `table` WHERE `birthday` LIKE '$year-$month%'");
"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
Ok I got it to email me... But the formatting is all wrong, first to get it to send anything through I query, and I recieve an email but it look slike thisPHP Code:LIKE '%$month%'"
Any ideas on this one?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)
Hiya any ideas why the email is doing the above? I got so close!
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:
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.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 '%$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); } ?>
"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
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?
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
Ok have it all up and running, it just does not like the, it seems to display them in the message. I tried adding <br> tags but they also just displayed in the message...PHP Code:r/n/
Bookmarks