PDA

View Full Version : Random item problem


gic0m
01-19-2002, 02:37 PM
How come this:

$query = "SELECT * FROM nesroms order by RAND() LIMIT 1";
$result = mysql_query($query);
$row = mysql_fetch_array($result);


Shows up an ERROR when I use it? 2 days ago it didnt, now all the sudden, it says:

Warning: Supplied argument is not a valid MySQL result resource in 1atop.php on line 279


Is there another way to select a random row from a DB?
Thanx in advance :)

dionyzos
01-29-2002, 01:58 AM
Make sure "nesroms" contains records and that it's spelled correctly. Sometimes, adding « or die(mysql_error()); » after the query-line helps a lot.

I fetch RANDOM ROWS on an hourly basis and it works fine.

Hope this helps.

- dionyzos.