What I want help with is that I also want the visitors who have subscribed to be able to unsubscribe. I have made following changes to function send($newsletter_id) in admin/newsletter.php:
function send($newsletter_id) {
$mail_query = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_newsletter = '1'");
$visitor_query = tep_db_query("select email from " . TABLE_VISITOR);
$mimemessage = new email(array('X-Mailer: osC mailer'));
// Build the text version
$text = strip_tags($text);
if (EMAIL_USE_HTML == 'true') {
$mimemessage->add_html($this->content);
} else {
$mimemessage->add_text($this->content);
}
while ($mail = tep_db_fetch_array($mail_query)) {
$mimemessage->add_html($this->content . TEXT_UNSUBSCRIBE . '<a href="' . HTTP_CATALOG_SERVER . DIR_WS_CATALOG . FILENAME_UNSUBSCRIBE . "?email=" . $mail['customers_email_address'] . '">' . HTTP_CATALOG_SERVER . DIR_WS_CATALOG . FILENAME_UNSUBSCRIBE . "?email=" . $mail['customers_email_address'] . '</a>');
$mimemessage->build_message();
$mimemessage->send($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], $mail['customers_email_address'], '', EMAIL_FROM, $this->title);
}
/////Simple Visitor Newsletter
while ($visitor = tep_db_fetch_array($visitor_query)) {
$mimemessage->add_html($this->content . TEXT_UNSUBSCRIBE . '<a href="' . HTTP_CATALOG_SERVER . DIR_WS_CATALOG . FILENAME_UNSUBSCRIBE . "?email=" . $visitor['email'] . '">' . HTTP_CATALOG_SERVER . DIR_WS_CATALOG . FILENAME_UNSUBSCRIBE . "?email=" . $visitor['email'] . '</a>');
$mimemessage->build_message();
$mimemessage->send('Besøkende - ' . ' ' . 'Fridas Barnebutikk', $visitor['email'], '', EMAIL_FROM, $this->title);
}
/////Simple Visitor Newsletter
$newsletter_id = tep_db_prepare_input($newsletter_id);
tep_db_query("update " . TABLE_NEWSLETTERS . " set date_sent = now(), status = '1' where newsletters_id = '" . tep_db_input($newsletter_id) . "'");
}
}
and tried this in unsubscribe_done.php:
<?php
// If we found the customers email address, and they currently subscribe
if ($cus_subscribe) {
// Unsubscribe them
tep_db_query("update " . TABLE_CUSTOMERS . " set customers_newsletter = '0' where customers_email_address = '" . $email_to_unsubscribe . "'");
} else if ($vis_subscribe) {
// Unsubscribe visitor
tep_db_query("delete from " . TABLE_VISITOR . " where convert ('" . TABLE_VISITOR . "''"."''"email"' using utf8) = '" . $email_to_unsubscribe . "'");
?>
<td class="main"><?php echo UNSUBSCRIBE_DONE_TEXT_INFORMATION . $email_to_unsubscribe; ?></td>
<?php
// Otherwise, we want to display an error message (This should never occur, unless they try to unsubscribe twice)
} else {
?>
<td class="main"><?php echo UNSUBSCRIBE_ERROR_INFORMATION . $email_to_unsubscribe; ?></td>
<?php
}
?>
But I am getting following error:
Parse error: syntax error, unexpected T_STRING in unsubscribe_done.php on line 76
Line 76 is quoted below:
tep_db_query("delete from " . TABLE_VISITOR . " where convert ('" . TABLE_VISITOR . "''"."''"email"' using utf8) = '" . $email_to_unsubscribe . "'");
Could someone please correct this query for me, as I can't find out whats wrong and where? Please advice














