Ver Mensaje Individual
  #9 (permalink)  
Antiguo 03/10/2011, 09:48
Avatar de cristian_cena
cristian_cena
Colaborador
 
Fecha de Ingreso: junio-2009
Mensajes: 2.244
Antigüedad: 14 años, 10 meses
Puntos: 269
Respuesta: Problemas para recorrer un arreglo: Undefined offset

La estructura de la tabla "especificaciones" es:
idespecificaciones INT NOT NULL auto_increment (PK)
productos_idproductos INT NOT NULL (FK)
grupos_idgrupos INT NOT NULL (FK)
status INT NOT NULL
descripcion TEXT NULL (Cotejamiento: utf8_general_ci)

Cita:
Iniciado por h2swider Ver Mensaje
Podrías hacerme un var dump de la consulta que te genera el problema.
Código PHP:
Ver original
  1. function addEspecificaciones($idproducto, $grupo, $estado, $descripcion){
  2.     $total = count($descripcion);
  3.     for($indice = 0; $indice < $total; $indice++){
  4.         $consulta = "INSERT INTO especificaciones VALUES(null, $idproducto, ".$grupo[$indice].", ".$estado[$indice].", '".$descripcion[$indice]."')";  
  5.         var_dump($consulta);
  6.         $conexion = crear_conexion(SERVER,USER,PASS); $db = DATABASE;   consulta_base_de_datos($consulta, $db, $conexion);
  7.     }  
  8. }

Esto devuelve.
string(68) "INSERT INTO especificaciones VALUES(null, 56, 3, 0, '<p>qweqwe</p>')"
<br />
<b>Notice</b>: Undefined offset: 1 in <b>C:\xampp\htdocs\sonomax\back\modulos\productos\ model.php</b> on line <b>130</b><br />
string(68) "INSERT INTO especificaciones VALUES(null, 56, 3, , '<p>8888888</p>')" (my god aca está!)

No encuentra .$estado[$indice] parece, puebo haber si es eso.