Notice: Trying to get property of non-object Here is my code:

function THEME_preprocess_block(&amp;$variables) {
    $variables['user_profile'] = menu_get_object('user');
}


I print the field "name" using print $user_profile-&gt;name, and I get the following error:


  Notice: Trying to get property of non-object in include() (line 71 of SITE\sites\all\themes\parce\block--block--2.tpl.php).


I assumed $user_profile was not an object and I tried print render($user_profile['name']), which returned me: 


  Fatal error: Cannot use object of type stdClass


What is going on? I checked the Drupal API reference, and menu_get_object() should return me an object.
You didn't print line numbers of the second error so I don't know if they happen on then same line. Maybe your notice is from something else.

What you could try is to print out the variable using print_r, vardump, debug or use the Devel module which creates some wrapper functions like dpm to print variables with Krumo.

It should be impossible that the same variable is an object and isn't an object at the same time. But it's hard to say more with the info you provided.

Update:
From your comments, I can see why you are getting the errors:

print $user_profile-&gt;field_country['und']['0']['value'];


Error >> Notice: Undefined index: und ...

print $user_profile['field_country']['und']['0']['value'];


Fatal >> Cannot use object of type stdClass as array

The problem as I marked in the error message is that und is not defined in the field value. So $user_profile-&gt;field_country is ok but $user_profile-&gt;field_country['und'] is undefined. The reason could be that it doesn't have a value set or that the language for the field isn't undefined. You should like I suggested above, print out the variable to see what it contains.