bu işinizi görür;
<?php
$resim[] = 'http://site.com/resim1.jpg';
$resim[] = 'http://site.com/resim2.jpg';
$resim[] = 'http://site.com/resim3.jpg';
$resim[] = 'http://site.com/resim4.jpg';
$resim[] = 'http://site.com/resim5.jpg';
$rastgele = $resim[rand(0, count($resim) - 1)];
?>
<a href="<?php echo $rastgele; ?>"><img src="<?php echo $rastgele; ?>" /></a>
bu arada ByMsT phpde random diye fonksiyon yok yanlış yazmışsın rand olacak