Jump to content

Recommended Posts

I have been trying to figure it out but I can't, any help appreciated.  8)

  $sql = "SELECT email_address FROM consultant WHERE con_id = '$con_id1'";
  $result=mysql_query($sql);
  $to = mysql_result($result, 0, 0);


  $sql = "SELECT email_address FROM consultant WHERE con_id = '$con_id2'";
  $result=mysql_query($sql);
  $to.= mysql_result($result, 0, 0);

  $sql = "SELECT email_address FROM consultant WHERE con_id = '$con_id2'";
  $result=mysql_query($sql);
  $to.= mysql_result($result, 0, 0);


  $sender = 'admin@salmonsreach.org';
  $headers = "SRC: Administrative Team";
  $message = "We would like to notify you that a client has booked an appointment with you. Thanks and Regards, SRC Administrative Team.";
  $message.= "<br /> Event date:  ".$event_start."\n";
  $message.= "<br /> Event end date: ".$end_date."\n";
  $message.= "<br /> Service: ".$service."\n";
  $message.= "<br /> Start time: ".$start_time."\n";
  $message.= "<br /> Address: ".$address_first_line."\n";
  $message.= "<br /> Post Code: ".$post_code."\n";

mail($to, $sender, $message, $headers);

Thanks and regs.

Link to comment
https://forums.phpfreaks.com/topic/159182-whats-wrong-with-my-mail-script/
Share on other sites

Look carefully at what you're telling your program to do:

<?php

  $sql = "SELECT email_address FROM consultant WHERE con_id = '$con_id1'";

  $result=mysql_query($sql);

  $to = mysql_result($result, 0, 0);

  // $to = 'asdf@asdf.com';

 

  $sql = "SELECT email_address FROM consultant WHERE con_id = '$con_id2'";

  $result=mysql_query($sql);

  $to.= mysql_result($result, 0, 0);

  // $to = $to . 'foobar@foobar.com'

  // ==> $to = 'asdf@asdf.com' . 'foobar@foobar.com'

  // ==> $to = 'asdf@asdf.comfoobar@foobar.com'

 

  $sql = "SELECT email_address FROM consultant WHERE con_id = '$con_id2'";

  $result=mysql_query($sql);

  $to.= mysql_result($result, 0, 0);

  // $to = $to . 'qwerty@qwerty.com'

  // ==> $to = 'asdf@asdf.comfoobar@foobar.com' . 'qwerty@qwerty.com'

  // ==> $to = 'asdf@asdf.comfoobar@foobar.comqwerty@qwerty.com'

 

 

  $sender = 'admin@salmonsreach.org';

  $headers = "SRC: Administrative Team";

  $message = "We would like to notify you that a client has booked an appointment with you. Thanks and Regards, SRC Administrative Team.";

  $message.= "<br /> Event date:  ".$event_start."\n";

  $message.= "<br /> Event end date: ".$end_date."\n";

  $message.= "<br /> Service: ".$service."\n";

  $message.= "<br /> Start time: ".$start_time."\n";

  $message.= "<br /> Address: ".$address_first_line."\n";

  $message.= "<br /> Post Code: ".$post_code."\n";

 

// $to contains: 'asdf@asdf.comfoobar@foobar.comqwerty@qwerty.com'

// Does $to look like a valid email address to you?

mail($to, $sender, $message, $headers);

?>

Change all instances of:

$to.= mysql_result($result, 0, 0);

 

to:

 

$to.= ', ' . mysql_result($result, 0, 0);

 

You should only make two changes based on the code you presented, i.e. you don't change the line: $to = mysql_...

 

Also it's really better if you throw just one query at the database rather than three, but you can work on that after you have the initial approach working.

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.