Question

Hi i've got new question :) im building simple newsletter with panel to send mails to registered users and newsletter mail addresses.

and i've got this code but newsletter goes only to registered users. can someone tell me why ?

    $zapytanie = mysql_query("SELECT login, imie, email FROM uzytkownicy UNION SELECT email,imie,login FROM newsletter");


    while($wynik=mysql_fetch_array ($zapytanie)) {


        $login2 = $wynik['login'];

        $imie = $wynik['imie'];

        $serwis_url = $zmienne['serwis_url'];

        $email = $wynik['email'];



        $tresc = '<!DOCTYPE HTML PUBLIC "-//W3C//Dtd HTML 4.0 transitional//EN">

<html><head><meta http-equiv="Content-type" content="text/html; charset=utf-8"></head>

<body bgcolor="#ffffff"><font face="Arial" style="font-size:13px;" color="#3E3E3E">'.nl2br(($wiadomosc)).'</font></BODY></HTML>';


      $headers = 'Reply-To: '.$zmienne['admin_email'].' <'.$zmienne['admin_email']."> \r\n"; 
        $headers .= 'From: "Administrator" <'.$zmienne['admin_email'].">\r\n"; 
        $headers .= "MIME-Version: 1.0 \r\n"; 
        $headers .= "Content-type: text/html; charset=utf-8 \r\n"; 

        $headers = 'Reply-To: '.$zmienne['admin_email'].' <'.$zmienne['admin_email']."> \r\n"; 
        $headers .= 'From: "Administrator" <'.$zmienne['admin_email'].">\r\n"; 
        $headers .= "MIME-Version: 1.0 \r\n"; 
        $headers .= "Content-type: text/html; charset=utf-8 \r\n"; 
      $headers = iconv("UTF-8","ISO-8859-2", $headers);


        $tresc = strtr($tresc, "\xA5\x8C\x8F\xB9\x9C\x9F", "\xA1\xA6\xAC\xB1\xB6\xBC");

        $tresc = str_replace("{login}",$login2,$tresc);

        $tresc = str_replace("{imie}",$imie,$tresc);

        $tresc = str_replace("{serwis_url}",$serwis_url,$tresc);

        $temat = str_replace("{login}",$login2,$temat);

        $temat = str_replace("{imie}",$imie,$temat);

        $temat = str_replace("{serwis_url}",$serwis_url,$temat);



        mail($email, $temat, $tresc, $headers);


    }


}
Was it helpful?

Solution

You have to have the same order of columns in your union select:

$zapytanie = mysql_query("SELECT login, imie, email FROM uzytkownicy UNION SELECT login, imie, email FROM newsletter");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top