NYCPHP Meetup

NYPHP.org

[nycphp-talk] Warning: 1 is not a valid File-Handle resource - HELP!

Phil Powell soazine at erols.com
Sun Dec 29 14:42:44 EST 2002


I got it this time, for once.. apparently I had an extra fclose() in my
statement!

Phil
----- Original Message -----
From: "Brian" <brian at preston-campbell.com>
To: "NYPHP Talk" <talk at nyphp.org>
Sent: Sunday, December 29, 2002 9:18 AM
Subject: Re: [nycphp-talk] Warning: 1 is not a valid File-Handle resource -
HELP!


> Not to add any further confusion if you are simply wish to fix what you
> have, but you could read the contents of your textfile into an array
> with file()
>
> $nicks = file("nicknames.txt");
>
> // You then use rtrim() to remove any unwanted whitespace,newlines, or
> carriage returns at the end of each item.
>
> foreach ($nicks as $nick) {
> $trimmed_nick = rtrim($nick);
> echo "$trimmed_nick<br>";
> }
>
> On Sun, 2002-12-29 at 04:10, Phil Powell wrote:
> > Ok, I am a bad coder. :(  I can't figure this out at all:
> >
> >    $fileID = fopen("nicknames.txt", 'r');
> >     $stuff = fread($fileID, filesize("nicknames.txt")); fclose($fileID);
> >     if (strlen($stuff) > 0) $priorNickNewLine = "\
";
> >     $nicks = explode("\
", $stuff);
> >
> > The last line produces the Warning.. why?  I am trying to read contents
from nicknames.txt and split according to the newline character so that each
nickname is an array element.
> >
> > What did I do wrong? :(
> >
> > Phil
> >
> >
> >
> >
> >
> >
> >
>
>
>
>
> --- Unsubscribe at http://nyphp.org/list/ ---
>
>




More information about the talk mailing list