That wierd.. I tried that myself, and got it to work prefectly.. Don't know why it doesn't work for you.. :\
If you don't get this working, you could do it like this:
$q = "SELECT max(id) FROM banners;";
/* perform the query and store the result in $result */
...
/* done */
$random_id = rand(1, $result);
/* now select the image */
$q = "SELECT * FROM banners WHERE id='$random_id';";
/* perform the query... */
That ought to work..
Good luck,
Olle