I have a small script that is fetching data as

Code:
$sql=mysql_query("SELECT * FROM messages LIMIT 9");
while($row=mysql_fetch_array($sql))
{
$msg=$row['msg'];
$mes_id=$row['mes_id'];
$up=$row['up'];
$down=$row['down'];
?>
I want to display the fetched data in Descending order based on the value in 'up' for each entry , so I tried that

Code:
$sql=mysql_query("SELECT * FROM messages  LIMIT 9 ORDER BY up DESC");
but I get the error "supplied argument is not a valid MySQL result resource"
What is the problem here

Thanks