title: Using file_exists to check if image exist before echo
body: <p>I'm trying to let my script check if an image exist before echoing it into my table. If it doesn't exist, it should echo another image in stead. My problem is that even though the image exist, it still goes to the else factor. Can anyone spot any coding mistakes?</p>
  
  <pre><code>&lt;?php
  mysql_select_db("xxxx");
  $result = mysql_query("SELECT * FROM yyyy WHERE frivillig=1 ORDER BY stilling");
  while($row = mysql_fetch_array($result))
  {
  ?&gt;
  &lt;tr&gt;
  &lt;td width="50px" class="frivillig"&gt;&lt;?php  if (file_exists($url . "ansatte" . "/" . (utf8_encode($row['etternavn'])) . "%20" . (utf8_encode($row['fornavn'])) . ".jpg")) {
  echo "&lt;img" . " " . "src='" . $url . "ansatte" . "/" . (utf8_encode($row['etternavn'])) . "%20" . (utf8_encode($row['fornavn'])) . ".jpg'" . " " . "height='50px'/&gt;";
  }
  else {
  echo "&lt;img" . " " . "src='" . $url . "images/mangler.png'" . " " . "height='50px'/&gt;";
  }
  ?&gt;
  </code></pre>
  
  <p>As you can see, I use $url for my complete url, and the images are placed in the /ansatte/ folder. </p>
  
  <p>Thanks for any help!</p>