How to fetch image from database in drupal
The style is an image style which is described a bit in Working with images in Drupal 7 and 8. I believe that you need to use Style_name as the 'style' in your code instead of 'public':

 $fid=$r['field_upload_photo_fid'];
 $file = file_load($fid);
 $variables = array(
 'path' =&gt; $file-&gt;uri,
 'style'=&gt;'Style_name'
 );
 print theme('image_style', $variables);


But also, what is the data in $file-&gt;uri? If you start with bad data then the result is also going to be bad.