title: Error writing to a text file using fwrite and file_put_contents
body: <p>I'm pretty new at using fwrite and file_put_contents and am getting errors on every line of my for loop statement:</p>
  
  <pre><code>Warning: file_put_contents() expects parameter 1 to be string,
  </code></pre>
  
  <p>or</p>
  
  <pre><code>Warning: fwrite(): 3 is not a valid stream resource in...
  </code></pre>
  
  <p>This is the code:</p>
  
  <blockquote>
    <p>$databank = "data.txt";   $access = fopen($databank, 'w')or die("cant
    open file");  fclose($access);</p>
  </blockquote>
  
  <pre><code>$row = "$ent1".' | '."$ent2".' | '."$perc1a".'% | '."$perc1a_frac".'% | '."$frac1a".' | '."$perc2a".'% | '."$perc2a_frac".'%  | '."$frac2a".' | +'."$a".' | '."$new_ent1".' | '."$perc1b".'% | '."$perc1b_frac".'% | '."$frac1b".' | '."$perc2b".'% | '."$perc2b_frac".'% | '."$frac2b".' \n';
              fwrite($access, $row);
              //file_put_contents($access,$row);
  </code></pre>
  
  <p>I have a hunch its a string related issue. Any pointers in greatly appreciated.</p>