db_query() to retrieve the image path using the fid
There is no need for manual queries.

You can load a file using file_load($fid), and then the path is in $file-&gt;uri. It might look a bit stringe ('public://something.jpg'), but that's a so called stream wrapper, and it works just fine with plain PHP file functions. 

It's not exactly clear to me what you are trying to achieve; if you want to render an image field from a node/user/..., there are better ways to embed title and things like that, but this would work if you really just have a field. (That you are trying to query the field data table suggests otherwise, though.)

&lt;?php
  $file = file_load($fid);
  $variables = array(
    'path' =&gt; $file-&gt;uri,
    'style_name' =&gt; 'your_style_name',
  );
  print theme('image_style', $variables);
?&gt;