Re: [PHP-DB] file and mail

2001-04-25 Thread Sigitas Paulavicius

> Hi all
>
> I have a text file with email addresses. Each line contains one email
> address. I read the file using file() function. Below is a snippet of my
> code
>
>  $staff = file("staff");
>  for($x=0; $x$to = $staff[$x];
>mail($to, "New User Added", $mailBody, "From: [EMAIL PROTECTED]");
>  }
>
>
> the snippet does send mail to all the address listed in the file staff but
> the header from of the mail is not [EMAIL PROTECTED], but when i replace
$to
> with a string like "[EMAIL PROTECTED]" everything works fine. The from  header is
> set to [EMAIL PROTECTED] and the subject also appears.
>
> I'm using php 4.0.1pl1 with apache 1.3 in a linux box. what could be the
> problem??
>
> kancha

Hi,

I suppose you should check if the values in $staff array are clear of
special chars.
Try trim()'ing them before sending to the functions. Otherwise use
var_dump($staff ) or print_r($staff ). Thy're quite handy while debuging.

Just a remark... the code here connects to smtp server, sends data and
disconnects N times - this is not quite efficent. SMTP protocol allows to
specify multiple recipients of single message in single connection (Of
course, this means you won't be using any mail() from PHP library...). Still
it's no problem as long as the list is reasonable in size.

Sigitas



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] How I can use multiple results in MySQL

2001-04-23 Thread Sigitas Paulavicius

> SELECT name FROM cia WHERE region =
> (SELECT region FROM table WHERE name = 'Brazil');

would be:
 SELECT cia.name
FROM cia, table
WHERE cia.region=table.region
AND table.name='Brazil'



> SELECT name FROM table WHERE count =
> (SELECT max(count) FROM table);

if there may be more than one record having maximum value, you will have to
run two separate queries


Sigitas



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]