You have to replace 20 with the number of images you have:
$rand = rand(0,20);
Did you named a picture 0.jpg ? cause 0 can also be generated by that rand() thing. And how many pictures do you have in that folder ?
If you make sure you have pics named from 1.jpg, 2.jpg, ... , 53.jpg, there always should be a pic shown =/ =P
the files are name 1.jpg ect upto 53.jpg and none are gif files.
EDIT:
Some files were in caps.
Thanks for all your help guys it looks great