Hoi,

Ik heb een programma gemaakt om nieuws brieven uit te sturen naar leden (± 2600) van onze vereniging.
Ergens loopt het fout want na 26 mails stopt het programma gewoon zonder fout melding.
------------------------------------------------------------
<html>
<head>
<meta http-equiv="refresh" content="3600">
</head>
<body>
<?php
$dag = date('d')-1;
if ($dag < 10)
{
$dag = "0".$dag;
}
$mnd = date('m');
$jr = date('Y');
$datum = $jr.'-'.$mnd.'-'.$dag.' 00:00:00';
$dag = date('d');
$datum2 = $jr.'-'.$mnd.'-'.$dag.' 00:00:00';
$koper = '1';
$koper1 = '0';
$koper2 = '11';
$server = "localhost";
$user = "";
$pass = "";
$database = "plant";
/* connectie naar mysql */
$dbh = mysql_connect($server,$user,$pass);
/* connectie met de database */
mysql_select_db($database,$dbh) or die('Database niet beschikbaar '.mysql_error());
$requete_sql = "select * from prijs where bijgewerkt > '".$datum."' and bijgewerkt < '".$datum2."'";
/* het resultaat opbouwen */
$query_result = mysql_query($requete_sql,$dbh);
/* vind ie iets? */
if (mysql_num_rows($query_result) > 0)
{
echo "ter is iets gevonden<br>";
$headers = "";
$message = "";
$subject = "Lijst van de op $dag - $mnd - $jr bijgewerkte of aangemaakte artikels # Liste des articles mis a jour ou nouvelles article du $dag - $mnd - $jr # List of the article updated or created on $dag - $mnd - $jr";

$message = '
<html>
<head>
<title>Lijst van de op $dag - $mnd - $jr bijgewerkte of aangemaakte artikels || Liste des articles mis a jour ou nouvelles article du $dag - $mnd - $jr || List of the article updated or created on $dag - $mnd - $jr </title>
</head>
<body bgcolor="#FFFFCC">
<p>test</p>
<HR>
<table border=1>
<tr>
<th><font size=2>Soortnaam</font></th><th><font size=2>Extra info</font></th><th><font size=2>Plantvorm</font></th><th><font size=2>Pot</font></th><th><font size=2>Hoogte</font></th><th><font size=2>Breedte</font></th><th><font size=2>[]</font></th><th><font size=2>CC</font></th><th><font size=2>€/-CC</font></th><th><font size=2>€/CC</font></th><th><font size=2>&nbsp;+CC&nbsp;</font></th><th><font size=2>€/+CC</font></th><th><font size=2>Producent</font></th>
</tr>
<tr>
<th><font size=2>Varietee</font></th><th><font size=2>Extra info</font></th><th><font size=2>Modelle</font></th><th><font size=2>Pot</font></th><th><font size=2>Hauteur</font></th><th><font size=2>Largeur</font></th><th><font size=2>[]</font></th><th><font size=2>CC</font></th><th><font size=2>€/-CC</font></th><th><font size=2>€/CC</font></th><th><font size=2>&nbsp;+CC&nbsp;</font></th><th><font size=2>€/+CC</font></th><th><font size=2>Producteur</font></th>
</tr>
<tr>
<th><font size=2>Variety</font></th><th><font size=2>Extra information</font></th><th><font size=2>Shape</font></th><th><font size=2>Pot</font></th><th><font size=2>Height</font></th><th><font size=2>Width</font></th><th><font size=2>[]</font></th><th><font size=2>CC</font></th><th><font size=2>€/-CC</font></th><th><font size=2>€/CC</font></th><th><font size=2>&nbsp;+CC&nbsp;</font></th><th><font size=2>€/+CC</font></th><th><font size=2>Grower</font></th>
</tr>
<tr>';
$wk1 = date('W');
if ($wk1 < 10)
{
$wk1 = 'wk0'.$wk1;
}
else
{
$wk1 = 'wk'.$wk1;
}
$wk2 = date('W')+1;
if ($wk2 > '52')
{
$wk2 = 'wk0'.($wk2-52);
}
else
{
if ($wk2 < '10')
{
$wk2 = 'wk0'.$wk2;
}
else
{
$wk2 = 'wk'.$wk2;
}
}
$wk3 = date('W')+2;
if ($wk3 > '52')
{
$wk3 = 'wk0'.($wk3-52);
}
else
{
if ($wk3 < '10')
{
$wk3 = 'wk0'.$wk3;
}
else
{
$wk3 = 'wk'.$wk3;
}
}
$wk4 = date('W')+3;
if ($wk4 > '52')
{
$wk4 = 'wk0'.($wk4-52);
}
else
{
if ($wk4 < '10')
{
$wk4 = 'wk0'.$wk4;
}
else
{
$wk4 = 'wk'.$wk4;
}
}
$wk5 = date('W')+4;
if ($wk5 > '52')
{
$wk5 = 'wk0'.($wk5-52);
}
else
{
if ($wk5 < '10')
{
$wk5 = 'wk0'.$wk5;
}
else
{
$wk5 = 'wk'.$wk5;
}
}
$requete_sql = "select om.om_français,om.productcod,prijs.$wk1,prijs.$wk2,prijs.$wk3,prijs.$wk4,prijs.$wk5,prijs.bijgewerkt,prijs.groepscode,prijs.s05_rijphd,prijs.p_f_0,prijs.pl_cc_0,prijs.foto,prijs.pr_qt_0,prijs.qt_cc_0,prijs.leverancie,prijs.partij,prijs.artikelcod,prijs.hoofdgroep,prijs.sleutelkod,prijs.s01_potmt,prijs.subgroep,prijs.s02_hmin,prijs.s54_plvorm,prijs.s04_brmin,prijs.pr_cc_0,prijs.pr__cc_0,s54.nederlands,s54.français,s54.english,s54.row_id from prijs as prijs, plantvormen as s54, artikellijst as om where prijs.bijgewerkt > '".$datum."' and prijs.bijgewerkt < '".$datum2."' and s54.row_id = prijs.s54_plvorm and prijs.artikelcod = om.productcod order by hoofdgroep,s01_potmt,s02_hmin,s04_brmin,pr_cc_0";
/* het resultaat opbouwen */
$query_result = mysql_query($requete_sql,$dbh);
/* vind ie iets? */
if (mysql_num_rows($query_result) > 0)
{
while($row = mysql_fetch_array($query_result))
{
$lev = $row["leverancie"];
$partij = $row["partij"];
$prodco = $row["artikelcod"];
$naam = $row["hoofdgroep"];
$naam2 = $row["om_français"];
$sleutel = $row["sleutelkod"];
$sub = $row["subgroep"];
$s01 = $row["s01_potmt"];
$s02 = $row["s02_hmin"];
$s04 = $row["s04_brmin"];
$s54 = $row["s54_plvorm"];
$prcc = $row["pr_cc_0"];
$prmcc = $row["pr__cc_0"];
$qt = $row["qt_cc_0"];
$prqt = $row["pr_qt_0"];
$plf = $row["p_f_0"];
$plcc = $row["pl_cc_0"];
$nl = $row["nederlands"];
$fr = $row["français"];
$en = $row["english"];
$foto = $row["foto"];
$photo = "http://www.pass-server.be/uploads/f".$row["sleutelkod"].".jpg";;
$s05 = $row["s05_rijphd"];
$gk = $row["groepscode"];
$wk01 = $row[$wk1];
$wk02 = $row[$wk2];
$wk03 = $row[$wk3];
$wk04 = $row[$wk4];
$wk05 = $row[$wk5];
if ($wk01 === "X" || $wk02 === "X" || $wk03 === "X" || $wk04 === "X" || $wk05 === "X")
{
if ($naam <> $naam2)
{
$naam = $naam." - ".$naam2;
}
if (substr($gk,1,1) <> "1")
{
if ($s05 > "0")
{
switch ($s05)
{
case "1" :
$nl = "<font color='green'><B>GESLOTEN KNOP - </B></font>".$nl." || <font color='green'><B>BOUTON FERME - </B></font>".$fr." || <font color='green'><B>CLOSED BUTTONS - </B></font>".$en;
break;
case "2" :
$nl = "<font color='purple'><B>KLEURTONEND - </B></font>".$nl." || <font color='purple'><B>MONTRANT COULEUR - </B></font>".$fr." || <font color='purple'><B>SHOWING COLOURS - </B></font>".$en;
break;
case "3" :
$nl = "<font color='red'><B>OPEN BLOEMEN + KLEURTONENDE KNOP - </B></font>".$nl." || <font color='red'><B>FLEURS OUVERT + BOUTONS MONTRANT COULEUR - </B></font>".$fr." || <font color='red'><B>OPEN FLOWERS + BOTTONS SHOWING COLOR - </B></font>".$en;
break;
case "4" :
$nl = "<font color='blue'><B>VOLLEDIG IN BLOEI - </B></font>".$nl." || <font color='blue'><B>ENTIEREMENT EN FLEURAISSON - </B></font>".$fr." || <font color='blue'><B>ENTIRELY OPEN FLOWERS - </B></font>".$en;
break;
case "5" :
$nl = "ZONDER KNOP - ".$nl." || PAS DE BOUTONS - ".$fr." || NO BUTTONS - ".$en;
break;
}
}
else
{
$nl = $nl." - ".$fr." - ".$en;
}
}
if ($foto === "X")
{
$message .= '<TD ALIGN=LEFT><B><font size=2><a href='.$photo.' TARGET="_blank">'.$naam.'</a></font></B></TD>';
$message .= '<TD ALIGN=RIGHT><B><font size=2><a href='.$photo.' TARGET="_blank">'.$sub.'</a></font></B></TD>';
$message .= '<TD ALIGN=LEFT><B><font size=2><a href='.$photo.' TARGET="_blank">'.$nl.'</a></font></B></TD>';
$message .= '<TD ALIGN=RIGHT><B><font size=2><a href='.$photo.' TARGET="_blank">'.$s01.'</a></font></B></TD>';
$message .= '<TD ALIGN=RIGHT><B><font size=2><a href='.$photo.' TARGET="_blank">'.$s02.'</a></font></B></TD>';
$message .= '<TD ALIGN=RIGHT><B><font size=2><a href='.$photo.' TARGET="_blank">'.$s04.'</a></font></B></TD>';
$message .= '<TD ALIGN=RIGHT><B><font size=2><a href='.$photo.' TARGET="_blank">'.$plf.'</a></font></B></TD>';
$message .= '<TD ALIGN=RIGHT><B><font size=2><a href='.$photo.' TARGET="_blank">'.$plcc.'</a></font></B></TD>';
$message .= '<TD ALIGN=RIGHT><B><font size=2><a href='.$photo.' TARGET="_blank">'.$prmcc.'</a></font></B></TD>';
$message .= '<TD ALIGN=RIGHT><B><font size=2><a href='.$photo.' TARGET="_blank">'.$prcc.'</a></font></B></TD>';
$message .= '<TD ALIGN=RIGHT><B><font size=2><a href='.$photo.' TARGET="_blank">'.$qt.' CC</a></font></B></TD>';
$message .= '<TD ALIGN=RIGHT><B><font size=2><a href='.$photo.' TARGET="_blank">'.$prqt.'</a></font></B></TD>';
$message .= '<TD ALIGN=RIGHT><B><font size=2><a href='.$photo.' TARGET="_blank">'.$lev.'</a></font></B></TD></tr>';
}
else
{
$message .= '<TD ALIGN=LEFT><B><font size=2>'.$naam.'</font></B></TD>';
$message .= '<TD ALIGN=RIGHT><B><font size=2>'.$sub.'</font></B></TD>';
$message .= '<TD ALIGN=LEFT><B><font size=2>'.$nl.'</font></B></TD>';
$message .= '<TD ALIGN=RIGHT><B><font size=2>'.$s01.'</font></B></TD>';
$message .= '<TD ALIGN=RIGHT><B><font size=2>'.$s02.'</font></B></TD>';
$message .= '<TD ALIGN=RIGHT><B><font size=2>'.$s04.'</font></B></TD>';
$message .= '<TD ALIGN=RIGHT><B><font size=2>'.$plf.'</font></B></TD>';
$message .= '<TD ALIGN=RIGHT><B><font size=2>'.$plcc.'</font></B></TD>';
$message .= '<TD ALIGN=RIGHT><B><font size=2>'.$prmcc.'</font></b></TD>';
$message .= '<TD ALIGN=RIGHT><B><font size=2>'.$prcc.'</font></B></TD>';
$message .= '<TD ALIGN=RIGHT><B><font size=2>'.$qt.' CC</font></B></TD>';
$message .= '<TD ALIGN=RIGHT><B><font size=2>'.$prqt.'</font></B></TD>';
$message .= '<TD ALIGN=RIGHT><B><font size=2>'.$lev.'</font></B></TD></tr>';
}
}
}
}
$message .= '
</table>
</body>
</html>
';

$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: [email protected]\r\n";
$headers .= "Reply-To: [email protected]\r\n";
$headers .= "Return-Receipt-To: [email protected]\r\n";
while($koper2 < 4000)
{
$requete_sql = "select naam,email from plant.test where row_id > $koper1 and row_id < $koper2";
$update = "De updates van $datum waren gevonden en de laatste verstuurd om ".date('H:i:s');
/* het resultaat opbouwen */
$query_result = mysql_query($requete_sql,$dbh);
/* vind ie iets? */
/*$to = "[email protected],";*/
if (mysql_num_rows($query_result) > 0)
{
/* en nu echot ie de info in de db die bij die rij hoort die gekozen is */
while($row = mysql_fetch_array($query_result))
{
set_time_limit(9000);
$eign = $row["naam"];
$eignem = $row["email"];
$to = $eignem;
mail("[email protected]",$subject,$message,$headers);
echo "koper ".$eign." heeft de mail ontvangen hij was de ".$koper." mail die verstuurd was<br>";
$koper = $koper+1;
}
$koper = 1;
}
$koper1 = $koper1+10;
$koper2 = $koper2+10;
}
echo $to;
echo "De updates zijn verzonden";
mail("[email protected]","De updates zijn verwerkt",$update);
}
?>
</body>
</html>
------------------------------------------------------------
wat is de error?
mischien een probleem met de execution time?
Zoek eens in info.php op hoeveel deze staat standaard meen ik op 30 sec.
zet anders een set_time_limit(100) bovenaan. Geeft 100 extra seconden aan je script.
Werkt alleen niet als PHP draait in safe-mode
zie ook:
http://nl2.php.net/manual/nl/function.set-time-limit.php
Eris schreef op 20.04.2006 18:57
wat is de error?

Er wordt geen error weergegeven. Het programma stopt gewoon met zenden
De mailservers die ik in beheer heb, zullen zulke hoeveelheden mail niet accepteren.
Klaasjan schreef op 20.04.2006 18:57
mischien een probleem met de execution time?
Zoek eens in info.php op hoeveel deze staat standaard meen ik op 30 sec.
zet anders een set_time_limit(100) bovenaan. Geeft 100 extra seconden aan je script.
Werkt alleen niet als PHP draait in safe-mode
zie ook:
http://nl2.php.net/manual/nl/function.set-time-limit.php

De safemode staat op off
die set-time-limit(100) waar moet die bovenaan staan. Nu staat ie tussen de while() van de query zelf. Ik heb onderstussen ook geprobeerd net na die <?php maar niks helpt.
SanThe schreef op 20.04.2006 19:45
De mailservers die ik in beheer heb, zullen zulke hoeveelheden mail niet accepteren.

Ik mail 1 per 1 dus niet alle 2600 in 1 mail, maakt dat een verschil?
Zou het helpen moest ik er bijvoorbeeld 25 verzenden dan het programma gedurende 10 seconden laten wachten en dan terug 25 mails verzenden?
Ik weet niet of het probleem is dat het script te lang werk heeft maar zoiets zou je kunnen proberen. Probleem is echter als je een scriptr schrijft wat dat kan dan moet het script weer een hele tijd actief zijn. En dat was nou net het probleem.

helemaal bovenaan pagina bijvoorbeeld
<?php set_time_limit(0) ?>

Nu staat de timelimit UIT!!!. du let op wat je doet je kunt nu een eeuwig script schrijven als het goed is.
Ik heb het op een andere manier gedaan.

Ik heb programma 1 die ik opstart en waar de 3 variabelen in SESSION worden aangemaakt

Door op de knop te klikken start hij het tweede programma op welke alle 30 seconden zichzelf herlaad maar de SESSION variabelen zijn ondertussen zo bijgewerkt dat hij de 10 volgende leden een mail verstuurd.
En dat werkt perfekt. Het is misschien iets trager maar na iets meer dan 2 uur zijn ze er toch door.

Bedankt allemaal voor vlotte en prachtige samenwerking.

Marc
Even wachten Marc, voor je wegloopt.;-) Ik snap je oplossing niet helemaal. Moet je nu twee uur lang telkens ergens op klikken?

Reageren