Re: [PHP] append line to text file HELP !!!

2002-04-28 Thread Richard Archer

At 1:28 AM -0400 29/4/02, eat pasta type fasta wrote:

>you might also want to use this format to open file

>$fp = fopen("your/path/goes/here", "a");
>$string_to_write = "$newmail" . "\n";
>fwrite($fp, $string_to_write);
>fclose($fp);


No point ignoring errors returned by functions.

Errors are there to help you pinpoint problems... they are noe
problems themselves.

 ...R.

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




Re: [PHP] append line to text file HELP !!!

2002-04-28 Thread eat pasta type fasta

check the read/write permissions in the folder the file is located in, 
they should be set to read/write/execute or th file will not be created,

you might also want to use this format to open file

$fp = fopen("your/path/goes/here", "a");

your code would look like this:




--__-__-__
eat pasta
type fasta


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




Re: [PHP] append line to text file HELP !!!

2002-04-28 Thread David Freeman

On 29 Apr 2002 at 0:26, Rodrigo wrote:

> Ok guys, this is the code and under it you can see what I get when I try
> to submit the form. 
>  
>  
>  $file_pointer=file('emails.txt','a') || exit;
> $string_to_write = ("$newmail")."\n";
> $s=fopen($file_pointer,$string_to_write);
> $s=fclose($fp);
> ?>
>  
>  
> Warning: Supplied argument is not a valid File-Handle resource in
> /home/restricted/home/h4ck3r/public_html/write.php on line 4
> 
> Warning: Supplied argument is not a valid File-Handle resource in
> /home/restricted/home/h4ck3r/public_html/write.php on line 6 
> 

I haven't actually checked your code on my development box and I 
haven't done file i/o for a while so this does not address any syntax 
errors that might exist, but...

What is the operating system?  Do you have sufficient permissions to 
be writing files in that directory?  What permissions are set on the 
file you're trying to append to?

If you can't work with files in that directory because of directory 
permissions then it won't work.  If the file has permissions that 
prevents the web server process from accessing it then you also won't 
be able to get it working.

CYA, Dave


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




RE: [PHP] append line to text file HELP !!!

2002-04-28 Thread John Holmes

Do you read the replies that were sent to you. Where did you get file()
from and why are you using fopen() to write to a file??

You're lucky Miguel is such a nice guy and helping you out.

---John Holmes...

> -Original Message-
> From: Rodrigo [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, April 28, 2002 8:26 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] append line to text file HELP !!!
> 
> Ok guys, this is the code and under it you can see what I get when I
try
> to submit the form.
> 
> 
>  $file_pointer=file('emails.txt','a') || exit;
> $string_to_write = ("$newmail")."\n";
> $s=fopen($file_pointer,$string_to_write);
> $s=fclose($fp);
> ?>
> 
> 
> Warning: Supplied argument is not a valid File-Handle resource in
> /home/restricted/home/h4ck3r/public_html/write.php on line 4
> 
> Warning: Supplied argument is not a valid File-Handle resource in
> /home/restricted/home/h4ck3r/public_html/write.php on line 6


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




Re: [PHP] append line to text file HELP !!!

2002-04-28 Thread Miguel Cruz

On Mon, 29 Apr 2002, Rodrigo wrote:
> Ok guys, this is the code and under it you can see what I get when I try
> to submit the form. 
>  
>  $file_pointer=file('emails.txt','a') || exit;
> $string_to_write = ("$newmail")."\n";
> $s=fopen($file_pointer,$string_to_write);
> $s=fclose($fp);
> ?>

Where did this code come from? It looks like you took what I mailed and
just sort of smudged it around into an incomprehensible, random mess.  
Let's look at it on a line-by-line basis:

> $file_pointer=file('emails.txt','a') || exit;

Here you changed "fopen" to "file" for some weird reason. Also, you don't 
tell it which directory the file "emails.txt" should be in. Put in a full 
pathname unless the web server actually has write privileges on the 
directory containing your script, in which case you have a whole different 
set of troubles.

> $string_to_write = ("$newmail")."\n";

Good enough, though it's easier to just write:

  $string_to_write = $newmail . "\n";

or even:

  $string_to_write = "$newmail\n";

> $s=fopen($file_pointer,$string_to_write);

Here you changed "fwrite" to "fopen" for, presumably, the same weird 
reason that you made the weird change above.

> $s=fclose($fp);

Where did $fp come from? The file pointer variable in this program is
called $file_pointer.

> Warning: Supplied argument is not a valid File-Handle resource in
> /home/restricted/home/h4ck3r/public_html/write.php on line 4

No surprise here. You can't randomly throw functions together. They all 
have specific purposes and expect specific types of inputs. I'd suggest 
two things:

1) Read the documentation carefully.

2) If someone gives you an example that might work, try it verbatim, and 
test after each change. Then you'll know when it went wrong.

miguel


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