title: PHP Dynamic text file creation
body: <p>I have this code </p>
  
  <pre><code>$ext = ".txt";
  $filename = $namef.$ext;
  if(!file_exists($filename))
  {
  $file = fopen($filename,"w");
  fwrite($file, $privatekey);
  fclose($file);
  chmod($file,0777);
  }
  </code></pre>
  
  <p><code>$namef</code> is any name that gets input into this program.
  However when I run this, I keep getting:</p>
  
  <pre><code>Unable to access (name_of_file).txt in something.php
  Warning: fopen(name_of_file.txt) [function.fopen]: failed to open stream: No such file      or directory in something.php 
  Warning: fwrite(): supplied argument is not a valid stream resource in ./something.php on line 79
  
  Warning: fclose(): supplied argument is not a valid stream resource in ./something.php on line 80
  
  Warning: chmod() [function.chmod]: Unable to access in ./something.php on line 81
  </code></pre>
  
  <p>May i know if dynamic text file name creation is possible?</p>
  
  <p>Thank you</p>