Try fflush($fp)
before closing.
Ignacio Vazquez-Abrams
2010-01-14 16:37:11
The code as written works for me; I'd suggest adding the following to determine where the error is happening:
<?php
$fp = fopen('sidebar_subscribers.txt', 'a') or die('fopen failed');
fwrite($fp, "$name\t$email\t$leader\t$industry\t$country\t$zip\r\n") or die('fwrite failed');
?>
The original error about an invalid stream resource was a result of not checking your return values, which the "or die()" essentially does for you. fopen was failing, and returning false, and you were passing false as the first argument to fwrite.
You can further check for errors by examining the return value of fwrite:
<?php
$ret = fwrite($fp, "$name\t$email\t$leader\t$industry\t$country\t$zip\r\n");
if ($ret === false)
die("Fwrite failed");
echo ("fwrite wrote $ret bytes");
?>