title: is_dir How to check if dir exists avoid error message
body: <p>I think I have missed something with the code below... Maybe you can help   </p>
  
  <pre><code>&lt;?php
      $imageurl = $pagename1;
      $imageurl = preg_replace('/\.asp/', ''.$g_sites_img2.'.jpg', $pagename1);
      $filename = $_SERVER{'DOCUMENT_ROOT'}.'/images'.$imageurl;
      if (file_exists($filename)) {
          echo '&lt;img src="'.$mainurl.'/images'.$imageurl.'" width="'.$g_sites_img2.'" align="left" /&gt;';
      } else {
          $imgremoteurl = $imgremoteurl.str_replace(' ', '_', strtolower($g_page_identify));
          $imageurlfolder = dirname($pagename1);
          mkdir($_SERVER{'DOCUMENT_ROOT'}.'/images'.$imageurlfolder, 0755, true);
          copy('http://www.dominate-seo.com/images/'.$imgfolder.'/'.$imgremoteurl.'.jpg', $_SERVER{'DOCUMENT_ROOT'}.'/images'.$imageurl);
          $thumb = new Imagick($_SERVER{'DOCUMENT_ROOT'}.'/images'.$imageurl);
          $thumb-&gt;scaleImage($g_sites_img2, 0);
          $thumb-&gt;writeImage($_SERVER{'DOCUMENT_ROOT'}.'/images'.$imageurl);
          $thumb-&gt;destroy();
      }
  ?&gt;
  </code></pre>
  
  <p>The code is suppose to check if a image exist. If the image does not exists it should create the image folder, but should not create it if it already exists. This is where my problem lies. If the folder exists it gives me an error</p>
  
  <blockquote>
    <p>Warning: mkdir() [function.mkdir]:
    File exists in
    /home/game1/public_html/includes</p>
  </blockquote>
  
  <p>If I refresh the page, the error message disappears when the file is created.</p>
  
  <p>How can I write the script so that it checks the folder, if it exists it does not throw the error?</p>