$valrand = 250+int(rand(251));

Il valore 501 in teoria non arriva mai, ma se e` questione importante conviene metterci un controllo.