server time delay for mailing list

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
russia5
Forum Newbie
Posts: 12
Joined: Sun May 22, 2005 8:07 pm
Location: California
Contact:

server time delay for mailing list

Post 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]
opengavel
Forum Newbie
Posts: 10
Joined: Tue Sep 12, 2006 2:06 pm
Location: Chicago

Post 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}
russia5
Forum Newbie
Posts: 12
Joined: Sun May 22, 2005 8:07 pm
Location: California
Contact:

Post 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]
arkady
Forum Newbie
Posts: 23
Joined: Sun Sep 17, 2006 9:34 pm

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Post Reply