"Undefined index" error for field which is defined I'm getting a strange error on a Views page, even though the page works. I get ten instances of this error: 

Notice: Undefined index: field_video in include() (line 28 of 
/path/to/drupal/sites/all/themes/mytheme/templates/
views-view-fields--screenings--panel-pane.tpl.php).

Notice: Trying to get property of non-object in include() (line 28 of 
/path/to/drupal/sites/all/themes/mytheme/templates/
views-view-fields--screenings--panel-pane.tpl.php).


Here's the content of line 28:

if (preg_match('/media/', $fields['field_video']-&gt;content)) {
    unset($fields['field_featured_image']);
}


The idea is that if a node of the relevant content type has both a Video and a Featured Image, the view will drop the image and replace it with the video. 

What's crazy is that the page renders just fine; the image disappears when the node has content in both fields. What's even crazier is that the error appeared after a minor tweak to the above code, so I reverted my change and it still throws this error, no matter how many times I flush my caches.

What is happening here? This very same code worked fine for a long time, but now I can't seem to get rid of this error!
First thing to note is you're seeing notices, not errors. Notices are a less severe type of PHP error. It's an alert that notes script execution is continuing, but something is wrong that could be a bigger problem. In your case, the array element $fields['field_video'] doesn't exist,
thus trying reference a property $fields['field_video']-&gt;content on a non-existant object causes PHP to fire off notices.

As Geoff mentioned, this can occur if your view rows are loading nodes that don't produce this field and throwing an isset($fields['field_video']) &amp;&amp; in your if statement should fix your template from making bad references.