DLR Posted June 27, 2006 Share Posted June 27, 2006 Hi all.I have a database with a lst of birthdays and have written a script to access the database on a daily basis. If there are any birthdays that day, it inserts the name from the database into the script and sends of an email to wish that person a happy birthday.If there is more than one person with a birthday on that day, it will send a separate email to each person having a birthday.Instead of just copying this letter(s) to me, I would like the script to send me one email with a list of the people having a birthday that day.I have tried to use an array, but do not seem to be able to get this to work - I get "resource#4" or something like that , in the email.My email script goes like this:$check_birthdays = "SELECT * FROM birthdays WHERE day = $today_day AND month = $today_month";$result = mysql_query($check_birthdays) or die(mysql_error());if (mysql_num_rows($result) >> 0 ) { //send email to each person who has a birthday today while ($row = mysql_fetch_array($result)) { extract($row); birthday_wishes(); // this is a function to insert the data from the table and send off the email - works fine } // send one email with list of all people having birthday today birthday_list()function birthday_list() {global $row;$to = "me";$from = "server";$subject2 = "Today's birthday list";$messagebody2 = "The following clients have birthdays today, " . date('d/F/Y') . " <p> " . print_r($result); Quote Link to comment Share on other sites More sharing options...
Wildbug Posted June 27, 2006 Share Posted June 27, 2006 1. Why are you using a bit-shift?[code]if (mysql_num_rows($result) >> 0 ) {[/code]2. Why don't you just compose a string to yourself while you loop through the results?[code]$text_to_myself = 'The following clients have birthdays today, ' . date('d/F/Y') . '<p>';while ($row = mysql_fetch_array($result)) { // .... I don't know what your rows are called, but... $text_to_myself .= "$row[firstname] $row[lastname] ($row[age])<br>\n"; // ....}$text_to_myself .= '</p>';// send it.[/code]If you're getting something like "resource#4", then you're probably trying to print the MySQL resource handle directly somehow. Quote Link to comment Share on other sites More sharing options...
fenway Posted July 3, 2006 Share Posted July 3, 2006 Well, you'd have to use mysql_fetch_assoc to get the hash back; also, any attempt to print $result directly is the source of your "resource #N" output. 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.