Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/07/2012, 15:11
Avatar de Middrel
Middrel
 
Fecha de Ingreso: abril-2005
Mensajes: 835
Antigüedad: 19 años
Puntos: 27
Warning en foreach de PHP

Hola, buenas tardes,

Tengo un error en una instrucción en PHP, que no sé el porqué de la misma, el error me marca:

Warning: Invalid argument supplied for foreach() in .... on line 12

la línea doce a la cuál hace referencia está aquí:


Código PHP:
<?
include ('session.php'); 
include (
'conectabd.php');
$coneccion=conectarse();

$accion="";

if (isset (
$_POST[pedido]))
{
    
$piezas="";
    
    foreach ( 
$_POST[cantidad] as $cant => $valor )      /* Esta línea */
    
{
        if (
$valor != "")
        {        
        
$piezas=$piezas $valor;        
        }
    }
    
}

?>
y yo le envío los parámetros desde aquí:

Código HTML:
<td colspan="4">
					<?
                    $selectDress="Select * from dress_pack ORDER BY `dress_pack`.`codigo` ASC";
                    $queryDress=mysql_query ($selectDress);
					$i = 0; $j = 0;
                    while ($rwwDress= mysql_fetch_object ($queryDress))
                    {
                    ?>        
                          <div style="border:solid 1px #EDD6CD; width:800px;">
                            <table width="100%">
                              <tr>
                                <td width="83%" align="left">
                                    <table>
                                        <tr>
                                            <td width="3%"><div class="stock"><? echo $rwwDress->stock ?></div></td>
                                            <td width="8%"><label><?php echo $rwwDress->nombre ?></label></td>
                                            <td width="10%"><input type="text" name="cantidad_<?php echo $i=$i+1; ?>" value="0" size="8%" style="text-align:center" /></td>
                                            <td width="1%"><label>$</label></td>
                                            <td width="20%"><input type="text" name="precio_<?php echo $j=$j+1; ?>" id="precio" value="0.00"size="15%" style="text-align:right"/></td>
                                        </tr>
                                    </table>
                                </td>
                              </tr>
                           </table>
                         </div>  
                    <?
                    }
                    ?>     
        		</td> 
Llevo un rato con esto y no sé si por ello no veo el error, alguien tiene alguna idea?

De antemano gracias, saludos!