Merhabalar,

Klasör içinde resimler var iken sorun yok ama içinde hiç resim yok ise hata veriyor.

<?php
$imgdir = '../resimler/'; // the directory, where your images are stored
$allowed_types = array('png','jpg','jpeg','gif'); // list of filetypes you want to show

$dimg = opendir($imgdir);
while($imgfile = readdir($dimg))
{
if(in_array(strtolower(substr($imgfile,-3)),$allowed_types))
{
$a_img[] = $imgfile;
sort($a_img);
reset ($a_img);
}
}

if ($a_img==0){

echo '<b>Sunucuda resim bulunamamıştır!!!</b>';

}else{

$totimg = count($a_img); // total image number

for($x=0; $x < $totimg; $x++)
{
$size = getimagesize($imgdir.'/'.$a_img[$x]);

// do whatever
$halfwidth = ceil($size[0]/2);
$halfheight = ceil($size[1]/2);
echo '<a href="../resimler/'.$a_img[$x].'" alt="resmin orjinal boyutlarını görmek için tıklayınız..." target="a_blank"><img src="../resimler/'.$a_img[$x].'" width = "300" height ="240" border="10" style="border-color:#000000"/></a>';
echo '<form id="form1" name="form1" method="post" action="resim_sil.php">
  <label>
   <input type="submit" name="Submit" value=" Resmi Sil" />
  </label>
  <label>
   <input type="hidden" name="silbilgi" value="../resimler/'.$a_img[$x].'" />
  </label>
</form>';
}
}
?>

Verdiği hata;

Notice: Undefined variable: a_img in C:\wamp\www\yonetim\resimler.php on line 29
Sunucuda resim bulunamamıştır!!! 
29. satır :

if ($a_img==0){
Kontrolü yanlış yere eklediğim belli ama acemi olduğum için yapamadım

böyle de denedim bu seferde resim yok yazmadı;

<?php
$imgdir = '../resimler/'; // the directory, where your images are stored
$allowed_types = array('png','jpg','jpeg','gif'); // list of filetypes you want to show

$dimg = opendir($imgdir);
while($imgfile = readdir($dimg))
{
if(in_array(strtolower(substr($imgfile,-3)),$allowed_types))
{
$a_img[] = $imgfile;
sort($a_img);
reset ($a_img);

$totimg = count($a_img); 

if ($totimg==0){

echo '<b>Sunucuda resim bulunamamıştır!!!</b>';

}else{

for($x=0; $x < $totimg; $x++)
{
$size = getimagesize($imgdir.'/'.$a_img[$x]);

// do whatever
$halfwidth = ceil($size[0]/2);
$halfheight = ceil($size[1]/2);
echo '<a href="../resimler/'.$a_img[$x].'" alt="resmin orjinal boyutlarını görmek için tıklayınız..." target="a_blank"><img src="../resimler/'.$a_img[$x].'" width = "300" height ="240" border="10" style="border-color:#000000"/></a>';
echo '<form id="form1" name="form1" method="post" action="resim_sil.php">
  <label>
   <input type="submit" name="Submit" value=" Resmi Sil" />
  </label>
  <label>
   <input type="hidden" name="silbilgi" value="../resimler/'.$a_img[$x].'" />
  </label>
</form>';
}
}
}
}

?>

Konuyla ilgilendiğiniz için şimdiden çok teşekkürler.