I got errors with this code:

 $node = node_load($data->nid);
$var1 = $node->body['und'][0]['value'];
$var2 = $node->field_bilder_f_r_die_galerie_2['und'][0]['value'] ;
if((!empty($var1)) || (isset($var2))){
echo "link";
}
else{
}
var_dump($var1);
var_dump($var2);

Everytime my variable is "NULL" i got this mistake. But some of my variables are NULL. What can i do ?

Error notice:

Notice: Undefined index: und in __lambda_func() (Zeile 3 von /home/bavramor/data/Webdesign/Webseiten/feuerwehr-germendorf/sites/all/modules/views_php/plugins/views/views_php_handler_field.inc(198) : runtime-created function).
Notice: Undefined index: und in __lambda_func() (Zeile 2 von /home/bavramor/data/Webdesign/Webseiten/feuerwehr-germendorf/sites/all/modules/views_php/plugins/views/views_php_handler_field.inc(198) : runtime-created function).

tested with :

7.x-1.0-alpha1
7.x-1.x-dev

any help would be appreciated

Comments

bavramor’s picture

Priority: Critical » Minor
Status: Needs work » Closed (fixed)

The mistake is here:

$var1 =  @$node->body['und'][0]['value']; ;
$var2 =  @$node->field_bilder_f_r_die_galerie_2['und'][0]['value'] ;
if((!empty($var1)) || (isset($var2)))

Now I write:

if((!empty($node->body['und'][0]['value'])) || (isset($node->field_bilder_f_r_die_galerie_2['und'][0]['value'] )))

An all errors are gone,

Greetz Bav

priyankprajapati’s picture

Title: Undefined index: und in __lambda_func() » Undefined index: 0 in __lambda_func
echo 'hi';
$query = db_query("select fa.field_currency_amount as amount from {field_data_field_currency} as fa inner join
 {field_data_field_date} as d on fa.entity_id = d.entity_id where fa.bundle=:bundle 
 and d.field_date_value = :date",array(':bundle' => 'add_income', ':date' => $data->field_field_date['0']['raw']['value']));

 foreach($query as $value){
	$final = $value->amount + $final;
} 
echo '$'.$final;

when i write this cod in global php filed then error will display like this.

Notice : Undefined index: 0 in __lambda_func() (line 5 of /var/www/html/java/drupal_fb/sites/all/modules/views_php/plugins/views/views_php_handler_field.inc(202) : runtime-created function)

how can i solve this error ???

priyankprajapati’s picture

Status: Closed (fixed) » Active
fizk’s picture

Maybe try $data->field_field_date[0]['raw']['value'] instead of $data->field_field_date['0']['raw']['value']

NancyDru’s picture

Note that ['und'] should be [LANGUAGE_NONE].

fizk’s picture

Status: Active » Closed (fixed)