Jump to content

Recommended Posts

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);

Link to comment
https://forums.phpfreaks.com/topic/13019-inserting-multiple-entries-in-email/
Share on other sites


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.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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