Very very strange problem (i hope i don't sound stupid here..)

<?php    

    $query  = "SELECT * FROM messages";
    $result = mysql_query($query);
    
$ret = mysql_query($query) or die(mysql_error());


            while($row = mysql_fetch_array($result, MYSQL_ASSOC))
            { 
            
                $to= $row['to'];                
                $from= $row['from'];
                $subject= $row['subject'];
                $message= $row['message'];
                $time= $row['time'];
                
                $query  = "SELECT * FROM users WHERE uid=$from";
                $new = mysql_query($query);
                $trow = mysql_fetch_array($new, MYSQL_ASSOC);
        
                $fname= $trow['firstname'];
                $lname= $trow['lastname'];
                $email= $trow['email'];


                echo 
            
                '
                     <tr>
                        <td class="style3"><input type="checkbox" name="payables[]" value='.$amount2.'></td>'.
                        "<td class='style3'>". $fname. " "  .$lname." </td>" .
                        "<td class='style3'>" .$email. "</td>" .
                        "<td class='style3'>" .$subject. "</td>" .
                        "<td class='style3'>" .$time. "</td></tr>"; 
        
                    
            }  
?>

Basically this query works fine and it outputs everything under the messages table. However, when I try to restrict the query by adding in

$query  = "SELECT * FROM messages WHERE to=$uid";

it has the [COLOR=Red]Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource [COLOR=Black]warning.

Btw, “to” is the way it is spelled/written out under the table and when outputting $uid by itself, it shows up… so I have no idea what I’m doing wrong here…
[/COLOR][/COLOR]