Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

fopen()
Is there something that says that I can only have only one file
open at a time?

The reason I ask is if I run two file open connections at the same time
my emailAddresses.txt file is read, but none of my emails are sent.
All of the data ends up in my error_file_log.txt. If I comment out the
second fopen() stream used for my error log my email program
works fine. Very strange behavior...

And while I am on the subject this code:
$file_emailErr = @fopen("emailErrorLog.txt", "a") or exit("Unable to open
file!");
$subject = "\n\n" . "Subject: " .$subject .
" \n**************************************
**********************\n";
@fwrite($file_emailErr, $subject);

outputs this text:

Subject: test  2
 ****************************************
********************

This code
if(!$mail->Send()){
$myString = $emailAdd . "\t" . $myName . "\n";
fwrite($file_emailErr, $myString);
}
outputs this text:
kraash@mysite.net
Kevin
asdf@asdf.com
Jone
qwer@asdfa.net
Jack
kraash@mysite.net
Kevin

Why is the name written to a newline in the second code example, but the
first
example works as it should?

insight always appreciated
thank you
Kevin



Report this thread to moderator Post Follow-up to this message
Old Post
Kevin Raleigh
08-18-07 03:00 AM


Re: fopen()
On Sat, 18 Aug 2007 04:37:29 +0200, Kevin Raleigh <kraleigh@sbcglobal.ne=
t>  =

wrote:

> Is there something that says that I can only have only one file
> open at a time?
>
> The reason I ask is if I run two file open connections at the same tim=
e
> my emailAddresses.txt file is read, but none of my emails are sent.
> All of the data ends up in my error_file_log.txt. If I comment out the=

> second fopen() stream used for my error log my email program
> works fine. Very strange behavior...

Should be no problem unless you get a variable clash...
This works perfectly:

<?php
$a =3D fopen(dirname(__FILE__).'/a','w');
$b =3D fopen(dirname(__FILE__).'/b','w');
fwrite($a,'This is a');
fwrite($b,'This is b');
fclose($a);
fclose($b);
?>


> And while I am on the subject this code:
> $file_emailErr =3D @fopen("emailErrorLog.txt", "a") or exit("Unable to=
open
> file!");
> $subject =3D "\n\n" . "Subject: " .$subject .
> " \n**************************************
**********************\n";
> @fwrite($file_emailErr, $subject);
>
> outputs this text:
>
> Subject: test  2
>  ****************************************
********************
>
> This code
>      if(!$mail->Send()){
>    $myString =3D $emailAdd . "\t" . $myName . "\n";
>    fwrite($file_emailErr, $myString);
>   }
> outputs this text:
> kraash@mysite.net
>      Kevin
> asdf@asdf.com
>      Jone
> qwer@asdfa.net
>      Jack
> kraash@mysite.net
>      Kevin
>
> Why is the name written to a newline in the second code example, but t=
he
> first
> example works as it should?

2 options:
1. There's a newline char in $emailAdd.
2. There is no actual newline, it's just how it looks due to wrapping in=
=

the viewport.
-- =

Rik Wasmus

Report this thread to moderator Post Follow-up to this message
Old Post
Rik
08-18-07 09:01 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP Language archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 11:48 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.