I dont know about the echo-ing but i got it working with a.hereseys code like this:
if(isset($_REQUEST['txtTo'])){
$toemail = $_REQUEST['txtTo'];
$subject1= $_REQUEST['txtSubject'];
$body1= $_REQUEST['txtBody'];
$headers1 = "From: name <email>" . "\r\n";
$headers1 .= 'MIME-Version: 1.0' . "\r\n";
$headers1 .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$splitdata = explode('; ', $toemail);
foreach($splitdata as $x){
$to1 = $x;
if (mail($to1, $subject1, $body1, $headers1)) {
echo("<p>success</p>");
} else {
echo("<p>failed... Please try again.</p>");
}
}
}
only thing is now that means that my database code must have been wrong. using "while" just repeated the emails being sent. i need to change this to a foreach command to be able to send the emails only once per address.
I am using the following code. How would i ammend the while command because the foreach needs ($something as $somethingelse) doesnt it?
$q = "SELECT DISTINCT email FROM orders";
$rs = $oAppl->query($q);
while ( $rw = $oAppl->row($rs) )
{
$to1 = $rw["email"];
$subject1 = $_REQUEST['txtSubject'];
$body1 = $_REQUEST['txtBody'];
$headers1 = "From: name <email>" . "\r\n";
$headers1 .= 'MIME-Version: 1.0' . "\r\n";
$headers1 .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
if (mail($to1, $subject1, $body1, $headers1)) {
echo("<p>success</p>");
} else {
echo("<p>"failed... Please try again.</p>");
}
}
NOTE: THIS CODE WORKS AS IT IS. I JUST NEED TO REPLACE THE WHILE COMMAND WITH A FOREACH COMMAND TO STOP IT REPEATING.
Thanks for your help guys its been really useful and helped me loads

i appreciate it
Edit: would i change
$q = "SELECT DISTINCT email FROM orders";
$rs = $oAppl->query($q);
while ( $rw = $oAppl->row($rs) )
{
$to1 = $rw["email"];
to:
$q = "SELECT DISTINCT email FROM orders";
$rs = $oAppl->query($q);
$rw = $oAppl->row($rs)
foreach ($rw['email'] as $emailaddress)
{
$to1 = $emailaddress;
Any help is appreciated