How to write a text file
<p>test.php opens test.txt and writes to it.  It works fine on one hosting server.</p>

<p>After migrating the code to another host, test.php now can't write out test.txt.  The error shows:</p>

<pre><code>Warning: fopen(/home/username/public_html/test.txt)
[function.fopen]: failed to open stream: Permission denied
</code></pre>

<p>It will only work when the test.txt file is set to 777.  On the original host, test.txt was set to 755.</p>

<p>What am I missing to give permission for test.php to write to the file without 777 on this new host?</p>

<p>Also, file upload PHP scripts aren't working either.</p>
