Thanks, My aim is to run this script at the end of each day so it will email me a list of all the new users.
My problem is trying to get the query to run and print out all results within the message part of the email. I am not using it for mailing list etc... its just a simple way of me getting a list of all new users. I need to know how to put the list into the message part of the mail function? Jambo -----Original Message----- From: DL Neil [mailto:[EMAIL PROTECTED]] Sent: 20 August 2002 17:12 To: James Meers Cc: [EMAIL PROTECTED] Subject: Re: [PHP-WIN] Query within Mail Function James, > I have a rather long list of names and I want to email the whole list and not one by one, do you know what I mean? May I suggest that you always reply to the list: someone else may answer better/faster/in color... Also how about a clear specification of need: why are you retrieving a subscriber's age if you're sending the same msg to everyone? That is why I thought you wanted to send personal messages! (not that I was even sure that was correct at the time...) There are regular discussions about the over-use of MAIL()/the limitations of the interface to SMTP servers, eg sending too many messages or overloading the To, CC, or BCC fields. I think the last ended but a day or so ago. Accordingly if your "rather long" is 'too long' then you're buying into problems! Mind you the above seems to apply mainly to *nix users - IIRC Windows users get a better deal from their implementation. Fortunately my client mailouts are very customised/sub-sets and the lists are therefore not very long - so I can't further offer useful advice on this. YMMV! The logic you appear to be discussing might look something like this: construct mail message/contents construct SQL query execute query check response clear addressee list (I tend to put myself/postmaster as the first name) while there's MySQL data available extract pertinent fields from MySQL resultset append separator character(s), name and email address fields to addressee list end while call MAIL() using addressee list Making sense now? =dn -----Original Message----- Hi James, Please bear with my limited knowledge of PHP... Does anyone know if it is possible to code a sql query within the message part of the mail function, e.g.: mail( "$to_mail","$sumject"," $sql = mysql_query("select * from table") or die("error with query\n"); while ($row = mysql_fetch_array($sql)) { $db_name=$row["name"]; $db_email=$row["email"]; $db_age=$row["age"]; echo"$name - $email - $age"; } " ); This obviously is wrong, does anyone know if its possible, if so, what is the right way of writing it?? =What's wrong with: $sql = mysql_query("select * from table") or die("error with query\n"); while ($row = mysql_fetch_array($sql)) { $db_name=$row["name"]; $db_email=$row["email"]; $db_age=$row["age"]; } etc... mail( "$to_mail","$sumject","$name - $email - $age" ); Regards, =dn -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php