Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php]funkcja mail() i petla while(), zatrzymuje się wykonywanie pętli
-Gość-
post
Post #1





Goście







Część!

Mam problem z pętlą while przy wysyłaniu maili za pomocą funkcji mail()

Skonstruowałem sobie cosik takiego:

  1. <?php
  2. $result = dbquery("SELECT * FROM `data` WHERE `Status`=0");
  3. $result2 = dbquery("SELECT * FROM `data` WHERE `Status`=1");
  4.  
  5. $rows = dbrows($result);
  6. $rows;
  7.  
  8. $rows2 = dbrows($result2);
  9. $rows2;
  10.  
  11. $licznik=0;
  12.  
  13. if (dbrows($result) != 0) {
  14.  
  15. while ($data = dbarray($result)) 
  16. if ($licznik<5)
  17. {
  18. {
  19.  
  20. srand((double)microtime()*1000000);
  21. $znacznik = md5(uniqid(rand()));
  22.  
  23.  
  24. $odbiorca=$data['Email'];
  25.  
  26. //to odpowiednio uzupelniam
  27. $tytul="";
  28. $nadawca = "";
  29. $nadawca_mail="";
  30.  
  31. // treść listu
  32. $tresclistu = "";
  33.  
  34. // definicja nagłówków
  35. $naglowki = "From: $nadawca <$nadawca_mail>\n";
  36. $naglowki .= "MIME-Version: 1.0\n";
  37. $naglowki .= "Content-Type: multipart/mixed;\n";
  38. $naglowki .= "\tboundary=\"___$znacznik==\"";
  39.  
  40. // nagłówki listu
  41.  
  42. $tresc="--___$znacznik==\n";
  43. $tresc .="Content-Type: text/html; charset=\"iso-8859-2\"\n";
  44. $tresc .="Content-Transfer-Encoding: 8bit\n";
  45. $tresc .="\n$tresclistu\n";
  46.  
  47. // wysłanie listu
  48.  if (mail($odbiorca,$tytul,$tresc,$naglowki))
  49.  {
  50.  
  51.  $result = dbquery("UPDATE data SET Status='1' WHERE Email='".$data['Email']."'");
  52. $rows--;
  53. $licznik++;
  54.  }
  55. }//while
  56. }//if
  57. }//if result
  58. ?>


No i problem jest taki, że wysyła tylko 1 maila i się zatrzymuje. A chciałbym, żeby wysłał 5 maili.

Potrzebne funkcje:

  1. <?php
  2. function dbquery($query) {
  3. $result = @mysql_query($query);
  4. if (!$result) {
  5. return false;
  6. } else {
  7. return $result;
  8. }
  9. }
  10.  
  11.  
  12. function dbresult($query, $row) {
  13. $result = @mysql_result($query, $row);
  14. if (!$result) {
  15. return false;
  16. } else {
  17. return $result;
  18. }
  19. }
  20.  
  21. function dbrows($query) {
  22. $result = @mysql_num_rows($query);
  23. return $result;
  24. }
  25.  
  26. function dbarray($query) {
  27. $result = @mysql_fetch_assoc($query);
  28. if (!$result) {
  29. return false;
  30. } else {
  31. return $result;
  32. }
  33. }
  34. ?>
Powód edycji: dodalem tag i bbcode (cysiaczek)
Go to the top of the page
+Quote Post

Posty w temacie
- Gość   [php]funkcja mail() i petla while()   20.09.2007, 11:07:17
- - Gość   Będę ogromnie wdzięczny za pomoc.   20.09.2007, 11:08:39
- - qqrq   Jak dla mnie coś pomieszałeś z kolejością ifów, al...   20.09.2007, 15:15:29


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 25.08.2025 - 16:25