Possible Duplicate:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
I am getting this error while trying to run a function. I am sending a value $id to this function and trying to return the associated array. But I get a warning supplied argument is not a valid MySQL-Link resource.
But if i run the same code by eliminating the function part and give a static value to $id it returns the result correctly. This is the function 
<?php
    mysql_select_db($database_spyware, $spyware);
    function get_product($id)
    {
        $query = sprintf("select product.descr as product_descr, product_id as Product_id,
                          category.descr as category from sp_url
                          inner join product
                          on product.id = sp_url.product_id
                          inner join category
                          on product.category_id = category.id
                          where sp_url.id = $id");
        $query_result = mysql_query($query, $spyware) or die(mysql_error());
        $row_rs_query = mysql_fetch_assoc($query_result);
        $totalRows_rs = mysql_num_rows($query_result);
        return($row_rs_query);
    }
?>
 
     
    