Undefined offset: 0

Started by Dhayzon, March 25, 2016, 10:03:55 AM

Previous topic - Next topic

Dhayzon

el error que me sale es el Undefined offset: 0 y me indica q esta en esta linea $avatarimg =  $memberContext[$id_usuario]['avatar']['href'] ;[/code]

por q me pasa eso _//  :-\
$posts = ssi_recentTopics(10, null, 'array');
   echo '
    <div  class="ssi_table"> <ul>';

  foreach ($posts as $post){
     
    $id_usuario = $post['poster']['id'];
    loadMemberData($id_usuario);
    loadMemberContext($id_usuario);
   $avatarimg =  $memberContext[$id_usuario]['avatar']['href'] ;

   

',($avatarimg) ? '<img src="'.$avatarimg.'"/>':'<img src="' . $settings['images_url'] . '/images/default.png"/>','

All Colours Sam

El error indica que la variable $id_usuario es un cero y el array $memberContext no contiene una entrada con un cero:  $memberContext[0]

Haz un var_dump sobre esa variable:  var_dump($id_usuario); para ver que es lo que contiene al momento de usarla en $memberContext


También asegúrate de globalizar la varialbe $memberContext al inicio de tu función.
Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

Dhayzon

suki exactamente pasa eso me di cuenta por que habilite para q los anonimos participen entonces $id_usuario  queda sin valor pero como lo lleno

tratare de solucionarlo ,  gracias c:   ya no hay dudas 

All Colours Sam

Puedes crearla tu mismo:

$memberContext[0] = array( aqui lo que sea que vayas a ocupar );
$avatarimg =  $memberContext[$id_usuario]['avatar']['href'] ;
Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

Dhayzon


Advertisement: