RE: Files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I am not sure what problems you are having, but....

Shouldn't the id's in the files match up?

So,

File1:
1, test@xxxxxxxx
2, test@xxxxxxxxx
3, test@xxxxxxxxx

File2:
1, doc1.doc
2, doc2.doc
3, doc3.doc


Also, where you are comparing the $groupid to the $id, shouldn't it be:

if($groupid == $id)

hth

Chris.

-----Original Message-----
From: Chris Grigor [mailto:thunderbox@xxxxxxxxx]
Sent: 28 June 2005 11:24
To: PHP General
Subject:  Files


*************************************

This e-mail has been received by the Revenue Internet e-mail service.

*************************************

Hey all,

I am having a bash at working with flat files.

What I am trying to achieve is the following

There are 2 files with info in them,

file1 has
id,email

and file2 has

id,filename

what I am trying to achieve is open up file1 get the id and email then
open file2 and match the id of file1 to id of file2, then if succesful
send a mail with the filename in file2.

Maybe have a look at the code...

$recp_list = fopen("mail_group_list.txt", "r");

while(!feof($recp_list))
{


	$line = fgets($recp_list, 255);
  

		$line = chop($line);


		$split = explode(",", $line);


		$id = $split[0];
	$email = $split[1];


	// time to mail.

        if ($email != "") {
		

	


$group_list = fopen("file_group_list.txt", "r");

while(!feof($group_list))
{
$groupline = fgets($group_list, 255);

$groupline = chop($groupline);

$groupsplit = explode(",", $groupline);

$groupid = $groupsplit[0];
$groupFileName = $groupsplit[1];

if($groupid = $id)
{
	


// start mailing
$fromname = "Test Mailer";
$fromaddress = "email@xxxxxxxxx";

$subject = "Test mail";
$message = "Test message $groupFileName";
$headers = "From: \"".$fromname."\" <".$fromaddress.">\n";
 

   // Notify the user on screen if the send was succesfull
   if(mail($email, $subject, $message, $headers))

			{

				print "Mail sent successfully to $email";
			}
			else
			{
				print "Mail not sent to $email";
			}


		

			}#end if groupid = id
}#end while group list
		}#end if email


}#end while email !=""
?>


So thats the mail.php

mail_list_group.txt looks like this


1,test@xxxxxxxx
5,test1@xxxxxxxx
7,test@xxxxxxxx

file_group_list.txt looks like this


2,filename1.doc
3,filename2.doc
4,filename3.doc

Any help on this would be great !

Cheers
Chris

PS the formatting might come out all wrong as its mailed from a web account.
--


-----------------------------------------------------------------------------
---------------
Anyone can give up smoking, but it takes a man to face cancer.

--

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





************************

This message has been delivered to the Internet by the Revenue Internet e-mail service

*************************

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux