Jump to content

Archived

This topic is now archived and is closed to further replies.

pewee

need help to modify a code

Recommended Posts

I need to send internal message to more than one user simultaneously. The system is made to send «one internal message to only one user" at the time.

The code used to send is:

[code]$sendto = 189;[/code]


when user ID is '189' , when I load the page it's working very well and sends message to member ID 189.

I wanted to send simultaneously to a list of user that I have 189, 234, 2578, 6890, etc.. that list can be located on an external txt file.

Each time a user will be sent a message an email is also send  by the system to inform him of a new message in his mail box.

It would be cool if I can have a 10 seconds pause between the sending...  let's say

[code]
$sendto = 189;
pause of 10sec
$sendto = 234
pause of 10sec
$sendto = 2578
etc...

[/code]


Any idea how to do that  ?

I 'll appreciate any help_ Thanks

Share this post


Link to post
Share on other sites
pause?  use the sleep() function ... sleep(10) pauses ten seconds

Share this post


Link to post
Share on other sites
Thanks for the reply,

[code]

sleep() function ;

$sendto = 189;
sleep(10);
$sendto = 234;
sleep(10);
$sendto = 2578;
... etc [/code]

is that what you have in mind?

Share this post


Link to post
Share on other sites
Almost. Just remove the line that says sleep() function; the rest is fine.

Share this post


Link to post
Share on other sites
Use this script to read a file line by line so u can store the numbers in the file as u suggested earlier.

<?php

        $lines = file('data.txt');

        foreach ($lines as $line_num => $line) {

          print $line;
        }

?>

Share this post


Link to post
Share on other sites
Hello, thanks for fast reply;

I tried that:
[code]
$sendto = 189;
sleep(10);
$sendto = 16067;
sleep(10);
[/code]

looks like something is missing, because I don't know why It is sending only to the last member ID "16067" not to the first "189"

Share this post


Link to post
Share on other sites
I don't think you can send e-mails just by assigning a value to a variable..

EDIT: how about just something like

[code]
<?php
foreach($members_array as $id)
{
  send_mail_function($id);
  sleep(10);
}
?>
[/code]

Where [b]$members_array[/b] holds all the member IDs and [b]send_mail_function(int id)[/b] sends the e-mail.

Share this post


Link to post
Share on other sites
Hello, this are not emails but internal messages sent within the program. The program then sends emails to inform members of a new messages.

The problem that I have today is that i cannot send more than ONE internal message at the time... I was trying to send one message to many members...

thanks for thr help

Share this post


Link to post
Share on other sites
[code]<?php
// ...
send_message(189);
sleep(10);
send_message(16067);
sleep(10);
// ...
?>[/code]

Edit: you obvisouly need to create the send_message() function.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.