This is my current code:
[pre]
// artiste_contact email part
for ($ea = 1; $ea <= 6; $ea++) {
$eartist .= "'".$emaildet['act_sent".$ea."']."', ";// may need to play with quote placement in this line
}
$eartist = substr($eartist, 0, -3);
//get email addresses from artise_contacts databases:
$artsql = "Select ".$quote."Act_Email".$quote." FROM ".$quote."artiste_contacts".$quote." where ".$quote."act_ID".$quote." IN (".$eartist.")";
$artist_email = execute_db($artsql, $conn);
$artemail = fetch_row_db ($artist_email);
foreach ($artemail['Act_Email'] as $emailartist){
$to_artists .= $emailartist.', ';
} // end foreach
$to_artists = substr($to_artists, 0, -2);
//end artiste_contact email part
[/pre]
OK, changed field name and loop start, so they are all act_sent1...act_sent6 and used your new line:
[pre]
$eartist .= "'".$emaildet['act_sent".$ea."']."', ";
[/pre]
But I still get the error: [08] Error: during query execution.
Select `Act_Email` FROM `artiste_contacts` where `act_ID` IN ('', '', '', '', '', ')
DBMS server said: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '')' at line 1
I did try changing the line:
[pre]
$eartist = substr($eartist, 0, -3);
[/pre]
to
[pre]
$eartist = substr($eartist, 0, -2);
[/pre]
(I think this removes the last ', ' doesn't it, whereas with your line above, won't it remove one character too many? Not sure I fully understand it though...)
But having changed this line I still get the error: Warning: Invalid argument supplied for foreach() in /home/y09dann/public_html/database/index.php on line 1025
Line 1025 starts: foreach ($artemail['Act_Email'] as $emailartist){
The full code for these email sendings (the part in index.php) is:
[pre]
if ($table_name == 'customer_booking_form') {
$email_details = execute_db($sql, $conn);
$emaildet = fetch_row_db ($email_details);
$emailto = $emaildet['email'];
$orderno = $emaildet['ID'];
$efirstname = $emaildet['firstname'];
$esurname = $emaildet['surname'];
$esvcreq = $emaildet['service_required'];
$etotprice = $emaildet['total_price'];
$ebookfee = $emaildet['booking_fee'];
$ebalance = $emaildet['balance'];
$from_address = 'bookings@mydomain.co.uk';
$to_addresses = '';
$cc_addresses = '';
$bcc_addresses = '';
$to_addresses = $emailto; // this is from the db query above (below echo $form
- use your own email to test email sending
// artiste_contact email part
for ($ea = 1; $ea <= 6; $ea++) {
$eartist .= "'".$emaildet['act_sent".$ea."']."', ";// may need to play with quote placement in this line
}
$eartist = substr($eartist, 0, -2);
//get email addresses from artise_contacts databases:
$artsql = "Select ".$quote."Act_Email".$quote." FROM ".$quote."artiste_contacts".$quote." where ".$quote."act_ID".$quote." IN (".$eartist.")";
$artist_email = execute_db($artsql, $conn);
$artemail = fetch_row_db ($artist_email);
foreach ($artemail['Act_Email'] as $emailartist){
$to_artists .= $emailartist.', ';
} // end foreach
$to_artists = substr($to_artists, 0, -2);
//end artiste_contact email part
foreach ($update_notice_email_cc_recipients_ar as $update_notice_email_cc_recipient){
$cc_addresses .= $update_notice_email_cc_recipient.', ';
} // end foreach
// you could put your email address in the $update_notice_email_cc_recipients_ar part of config.php OR hardcode your email address here if you want to get a cc on these mailings - leave as is / blank in config if you don't want cc on email - this you will need to decide how you want to use ...
$cc_addresses = substr($cc_addresses, 0, -2); // delete the last ', '
foreach ($update_notice_email_bcc_recipients_ar as $update_notice_email_bcc_recipient){
$bcc_addresses .= $update_notice_email_bcc_recipient.', ';
} // end foreach
$bcc_addresses = substr($bcc_addresses, 0, -2); // delete the last ', '
$additional_headers = '';
if ($cc_addresses != '') {
$additional_headers .= "Cc:".$cc_addresses."\n";
} // end if
if ($bcc_addresses != '') {
$additional_headers .= "Bcc:".$bcc_addresses;
} // end if
if ($from_address != '') {
$additional_headers .= "From: ".$from_address."\r\n".
"Reply-To: ".$from_address."\r\n".
"X-Mailer: PHP/".phpversion();
} // end if
// modify the text below which will go into your subject line:
if (isset($_GET["receipt"]) && ($_GET["receipt"] != '')) {
$msgset = $_GET["receipt"];
$msgtype = 'Payment Receipt';
$reminder_email = 'my message content'; // have removed the actual content for ease of reading
//mail(TO, SUBJECT, MESSAGE, HEADERS(CC, BCC, etc));
//make adjustments as needed to the mail line:
if (mail($to_addresses, $msgtype.' - '.$orderno, $reminder_email, $additional_headers)) {
$msgsent = ' - Receipt email sent';
// update the record
update_sent('emailstatus', $table_name, $table_internal_name, $where_field, $where_value, 'receipt');
echo "<script type='text/javascript'>
alert('$msgsent to $emailto');</script>";
}
} elseif (isset($_GET["latepmt"]) && ($_GET["latepmt"] != '')) {
$msgset = $_GET["latepmt"];
$msgtype = 'Payment Overdue';
$reminder_email = 'Message content'; // again, removed for ease of reading
if (mail($to_addresses, $msgtype.' - '.$orderno, $reminder_email, $additional_headers)) {
$msgsent = ' - Late Payment email sent';
// update the record (emailstatus is your email status db field name)
update_sent('emailstatus', $table_name, $table_internal_name, $where_field, $where_value, 'latepmt');
echo "<script type='text/javascript'>
alert('$msgsent to $emailto');</script>";
}
} elseif (isset($_GET["artist"]) && ($_GET["artist"] != '')) {
$msgset = $_GET["artist"];
$msgtype = 'Message to Artists';
$reminder_email = 'email message content';
if (mail($to_artists, $msgtype.' - '.$table_name.' - '.$normal_messages_ar['new_update_executed'], $reminder_email, $additional_headers)) {
$msgsent = ' - Job Details sent to act';
// update the record
update_sent('emailstatus', $table_name, $table_internal_name, $where_field, $where_value, 'artist');
}
} else {
$msgset = '';
$msgtype = '';
$msgsent = '';
$reminder_email = '';
}
txt_out('<ul type="disc"><strong>Email actions will be sent to:</strong> '.$to_addresses.'<ul type="disc">');
//receipt email link
txt_out('<li>[url='.preg_replace(]Send Receipt Email[/url]'.$msgsent);
// late payment reminder
txt_out('<li>[url='.preg_replace(]Send Late Payment Reminder Email[/url]'.$msgsent);
txt_out('</ul></ul>'); // closes the list
// artist email job details notice
txt_out('<ul type="disc"><strong>Job details will be sent to:</strong> '.$to_artists.'<ul type="disc">');
txt_out('<li>[url='.preg_replace(]Send Job Details to Performer(s)[/url]'.$msgsent);
txt_out('</ul></ul>'); // closes the list
} // end code addition for email links in customer_booking_form table edit pages
[/pre]