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

**URL:** <https://forum.kirupa.com/t/very-very-strange-problem-i-hope-i-dont-sound-stupid-here/252826>\
**Category:** Uncategorized\
**Created:** [February 24, 2008, 5:43am UTC](https://forum.kirupa.com/t/very-very-strange-problem-i-hope-i-dont-sound-stupid-here/252826 "2008-02-24T05:43:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![xpiamchris](https://avatars.discourse-cdn.com/v4/letter/x/c4cdca/32.png) [@xpiamchris](https://forum.kirupa.com/u/xpiamchris)\
**Post date:** [February 24, 2008, 5:43am UTC](https://forum.kirupa.com/t/very-very-strange-problem-i-hope-i-dont-sound-stupid-here/252826/1 "2008-02-24T05:43:08Z")

</div>

```auto
<?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

```auto
$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]
