title: PNG file is not valid error when reading path from DB but works if the path is hardcoded
body: <p>I run PHP 5.2 on Ubuntu with Apache 2.</p>
  
  <p>When I want to serve a PNG file from PHP file which is hardcoded (using <code>$imgname</code>), I can succeed. However if I change the <code>$imgname</code> to <code>$imgdbname</code>, the browser fails and says it is not a valid PNG file.</p>
  
  <pre><code>$imgname = "cachepics/c3s9taopkp.png";
  $imgdbname = readfromdb();
  
  header("Content-type: image/png");
  print file_get_contents($imgname);
  </code></pre>
  
  <p>However if I comment the <code>header("Content-type: image/png");</code> line, browser shows the all PNG garbage text in both cases. Therefore, I am sure the PHP instance is able to reach that file by reading the path from DB.</p>
  
  <p>The ouput of</p>
  
  <pre><code>print "-".$imgname."-".$imgdbname."-";
  </code></pre>
  
  <p>seems exactly the same. </p>
  
  <pre><code>-cachepics/c3s9taopkp.png-cachepics/c3s9taopkp.png-
  </code></pre>
  
  <p>I will go crazy and don't know why the db version does not work.</p>