Page 1 of 1

server time delay for mailing list

Posted: Mon Sep 18, 2006 10:21 am
by russia5
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hello, I am creating a timedelay for an email mailing list.  The code I have now without the time delay works:

Code: Select all

$headers  = "From: $from\r\n"; 
$headers .= "Content-type: text/html\r\n";

include_once ("config.php");

//Get emails from email List
$result = mysql_query("SELECT email FROM db_tbl WHERE status = '1'");
if (!$result) {
   echo 'Could not run query: ' . mysql_error();
   exit;
}

while ($row = mysql_fetch_object($result)) {
    echo $row->email;
    mail($row->email, $subject, $message, $headers); 
    
}

mysql_free_result($result);

  ?>
When I add the timing code:

Code: Select all

$headers  = "From: $from\r\n"; 
$headers .= "Content-type: text/html\r\n";

include_once ("config.php");

$x =1;  
$hold =10; 

do{  
//Get emails from Latest_Ladies_email List 

$result = mysql_query("SELECT email FROM db_tbl WHERE status = '1'");
if (!$result) {
   echo 'Could not run query: ' . mysql_error();
   exit;
}
   $x++;  
   if($x == $hold) {  
       set_time_limit(30);  
       sleep(3);  
       $x = 0;  

}

}
while ($row = mysql_fetch_object($result)) {
    echo $row->email;
    mail($row->email, $subject, $message, $headers); 
    
}

mysql_free_result($result);
?>
The error I am getting is:

Code: Select all

Parse error: parse error, unexpected '{', expecting ';' in /home/russia5/public_html/mailer/APEX_mime.php on line 154
Line 154 is the while() line

Can anyone see the syntax error I am making.

Thanks to all that try to help me!

Greg


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Mon Sep 18, 2006 3:29 pm
by opengavel
It looks like the format of your do-while loop is messed up, hence the parse error.


Should be:

do {something} while (something is true)

or

while (something is true) {something}

You have:

do {something} while (something) {something}

Posted: Mon Sep 18, 2006 6:43 pm
by russia5
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Thankyou very much!  After reading your opinion, and looking at the do while construct a little more careful, I believe that the FOR loop has a better chance at doing this.  I am a fairly new coder, so what might be obvious to you guys, is not to me.  But hopeully, that will change.

Anyway, I am still getting a problem, but I believe it is more along the a more "doable" path.  Would it be asking to much for someone with great eyes to look at this and maybe spot what I have not been able to after a day of work on it?

Here is my new code.

Code: Select all

$i =1;
$hold =10;



for ($i == $hold; set_time_limit(30); sleep(3); $i = 0; i++){

//Get emails from Latest_Ladies_email List

$result = mysql_query("SELECT email FROM Latest_Ladies_email WHERE status = '1'");

if (!$result) {
   echo 'Could not run query: ' . mysql_error();
   exit;
}

else

$row = mysql_fetch_object($result)) {
    echo $row->email;
    mail($row->email, $subject, $message, $headers); 
    
}
}
mysql_free_result($result);
Here is my error:

Code: Select all

Parse error: parse error, unexpected ';', expecting ')' in /home/russia5/public_html/mailer/APEX_mime.php on line 133
Where line 133 is the FOR() line.

Thanks again... Greg


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Mon Sep 18, 2006 6:54 pm
by arkady
your for loop is not expecting so many statements

Code: Select all

for ($i = 0; $i < $hold; $i++)
{
  set_time_limit(30);
  sleep(3);
...
}
Is this more like what you're attempting to do?

Posted: Mon Sep 18, 2006 7:45 pm
by feyd
russia5, I've had to edit half of your posts to add/change

Code: Select all

tags to your posts. Please start using the correct tags.