title: PHP warning from root directory
body: <p>I have a problem with a php code.</p>
  
  <p><strong>Folder name</strong> what-counter This folder contains a file with the following php code named counter.php also the hitcount.txt file.</p>
  
  <pre><code>&lt;?php
  
  $filename = '../what-counter/hitcount.txt';
  $handle = fopen($filename, 'r');
  $hits = trim(fgets($handle)) + 1;
  fclose($handle);
  
  $handle = fopen($filename, 'w');
  fwrite($handle, $hits);
  fclose($handle);
  
  // Uncomment the next line (remove //) to display the number of hits on your page.
  echo $hits;
  
  ?&gt;
  </code></pre>
  
  <p>The following php code is used in root directory files also in files from folders which echo's the hits.</p>
  
  <pre><code>&lt;?php include("../what-counter/counter.php"); ?&gt;
  </code></pre>
  
  <p><strong>The problem</strong>
  The code works in the files in folders but not in the files that are directly in the root directory.
  Example: index.php is in the root directory</p>
  
  <p><strong>Using this code i get this Warning</strong></p>
  
  <pre><code>&lt;?php include("what-counter/counter.php"); ?&gt;
  
  Warning: fopen(../what-counter/hitcount.txt) [function.fopen]: failed to open stream: No such file or directory in /home/what/public_html/what-counter/counter.php on line 4
  
  Warning: fgets(): supplied argument is not a valid stream resource in /home/what/public_html/what-counter/counter.php on line 5
  
  Warning: fclose(): supplied argument is not a valid stream resource in /home/what/public_html/what-counter/counter.php on line 6
  
  Warning: fopen(../what-counter/hitcount.txt) [function.fopen]: failed to open stream: No such file or directory in /home/what/public_html/what-counter/counter.php on line 8
  
  Warning: fwrite(): supplied argument is not a valid stream resource in /home/what/public_html/what-counter/counter.php on line 9
  
  Warning: fclose(): supplied argument is not a valid stream resource in /home/what/public_html/what-counter/counter.php on line 10
  </code></pre>
  
  <p><strong>And using this code i get this Warning</strong></p>
  
  <pre><code>&lt;?php include("../what-counter/counter.php"); ?&gt;
  
  Warning: include(../what-counter/counter.php) [function.include]: failed to open stream: No such file or directory in /home/what/public_html/include/footer.php on line 31
  
  Warning: include(../what-counter/counter.php) [function.include]: failed to open stream: No such file or directory in /home/what/public_html/include/footer.php on line 31
  
  Warning: include() [function.include]: Failed opening '../what-counter/counter.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/what/public_html
  /include/footer.php on line 31
  </code></pre>
  
  <p>What can i do to the $filename url and <code>&lt;?php include("../what-counter/counter.php"); ?&gt;</code> to get it to work in files in root directory as well as folders?</p>