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. 
>  
> <?php
> $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

Reply via email to