Ver Mensaje Individual
  #2 (permalink)  
Antiguo 03/07/2012, 16:56
Avatar de Triby
Triby
Mod on free time
 
Fecha de Ingreso: agosto-2008
Ubicación: $MX->Gto['León'];
Mensajes: 10.106
Antigüedad: 15 años, 8 meses
Puntos: 2237
Respuesta: Error (Notice: Undefined offset: 21 in C:\xampp\htdocs\eventcal\calendar.p

Código PHP:
Ver original
  1. $events = array();
  2.  
  3. $result = mysql_query("SELECT DATE_FORMAT(eventDate,'%d') AS day,eventContent,eventTitle FROM eventcal WHERE eventDate BETWEEN  '$current_year/$current_month/01' AND '$current_year/$current_month/$total_days_of_current_month'");
  4.  
  5. while($row_event = mysql_fetch_object($result))
  6. {
  7.     //El error me lo marca en este linea de abajo
  8.     $events[intval($row_event->day)] .= '<li><span class="title">'.stripslashes($row_event->eventTitle).'</span><span class="desc">'.stripslashes($row_event->eventContent).'</span></li>';
  9. }

$events es un array vacío, no hay elementos, intentas concatenar algo a un elemento que no existe y es cuando obtienes el mensaje.

La solución es sencilla, si no existe el elemento, lo creas con un valor inicial y listo; ejemplo:

Código PHP:
Ver original
  1. if( ! isset($arreglo['elemento'])) {
  2.     $arreglo['elemento'] = '';
  3. }
  4. $arreglo['elemento'] .= '¡Ya puedo concatenar sin problemas!';
__________________
- León, Guanajuato
- GV-Foto