Foros del Web » Programando para Internet » PHP »

Warning: pg_fetch_array()

Estas en el tema de Warning: pg_fetch_array() en el foro de PHP en Foros del Web. ayuda con este error.... como recorro el array de la funcion? bueno aca estan 2 form... el 1ro es para seleccionar una patente a editar ...
  #1 (permalink)  
Antiguo 08/04/2011, 15:25
Avatar de xamilo  
Fecha de Ingreso: febrero-2010
Mensajes: 120
Antigüedad: 14 años, 2 meses
Puntos: 1
Warning: pg_fetch_array()

ayuda con este error.... como recorro el array de la funcion?

bueno aca estan 2 form...
el 1ro es para seleccionar una patente a editar
y el segundo para mostrar dicha patente...

Código PHP:
Ver original
  1. <form id="muestra" name="muestra" method="post" action="editar_vehiculo.php" enctype="multipart/form-data">
  2.  <div id="inf-puesto" align="center">
  3.     <table width="945" border="0" cellpadding="5" cellspacing="0">
  4.     <tr><ul id="navlist">
  5.          <td width="156" rowspan="3" align="right" ><span> Seleccione el vehiculo a editar : </span></td>
  6.          <td width="189" rowspan="3"align="left"><select name="s_id">
  7.         <?php while($row6 = pg_fetch_array($res6))
  8.         {   ?>
  9.          <option value="<?php echo( $row6["vehi_id"] )?>" <? echo "selected=\"selected\""  ?> ><?php echo( $row6["vehi_patente"] )?></option>
  10.                                      <?php } ?>
  11.         </select></td>
  12.     </ul></tr>
  13.     <tr>
  14.         <td class="TDX1" colspan="2" align="center">
  15.             <input type="submit" name="muestra" value="Muestra">
  16.         </td>
  17.     </tr>
  18.     </table>
  19.  </div>    
  20. </form>    
  21.        
  22. <?php
  23.   if ($seg == 1) {
  24. ?>        
  25. <form id="form" name="form" method="post" action="editar_vehiculo.php" enctype="multipart/form-data">
  26. <input type="hidden" name="accion" value="agregar" />
  27.  
  28.     <div id="inf-puesto" align="center">
  29.    
  30.     <table width="945" border="0" cellpadding="5" cellspacing="0">
  31.     <?php
  32.    
  33. while ($row = pg_fetch_array($regvehi) ) // aca mi error.. como recorre mejor el arreglo?
  34.     {
  35.         $vehi_pate = $row['vehi_patente'];
  36.         $vehi_duen = $row['vehi_dueno'];
  37.         $vehi_esta = $row['vehi_estado'];
  38.         $vehi_obsv = $row['vehi_observaciones'];
  39.     ?>
  40.     <tr><ul id="navlist">
  41.          <td width="156" rowspan="3" align="right" ><span>Patente :</span></td>
  42.          <td width="189" rowspan="3"align="right"><input name="vehi_patente" class="caja-vehi" value="<?php echo $vehi_pate; ?>" /></td>
  43.          <td width="122" rowspan="3" align="right" ><span>Due&ntilde;o :</span></td>
  44.          <td width="122" align="left"><input name="vehi_dueno" class="caja-vehi" value="<?php echo $vehi_duen;?>"></td>
  45.          <td width="122" rowspan="3" align="right" ><span>Estado :</span></td>
  46.          <td width="130" align="left"><input name="vehi_estado" class="caja-vehi" value="<?php echo $vehi_esta;?>" /></td>
  47.      </ul></tr>
  48.     </table>
  49.    <br />
  50.     <ul id="navlist">
  51.     <li><span>Observaciones</span><textarea name="vehi_observaciones" class="cajaobs" rows="4" cols="80"><?php echo $vehi_obsv; ?></textarea></li>
  52.     </ul>
  53.     <?php } ?>
  54.     </div>
  55.            
  56.     <br/><br/><br/>
  57.     <div id="inf-puesto" align="center">
  58.         <input name="enviar3" type="submit" value="Enviar" />
  59.         <input name="limpiar" type="reset" value="Limpiar">
  60.     </div> 
  61. </div>
  62.  
  63. </form>
  64. <?php } ?>

aca las funciones y querys para updatear dicha patente

Código PHP:
Ver original
  1. function selecciona($mues)
  2. {
  3. $query = "SELECT * from flotas.vehiculos WHERE vehi_id = '$mues'";
  4. $result = pg_query($query);
  5. $reg = pg_fetch_array($result);
  6. }
  7.  
  8. $seg = 0;
  9.  
  10. if ($_POST["muestra"])
  11. {
  12.     $seg = 1;
  13.     $mues = $_POST['s_id'];
  14.    
  15.     $regvehi = selecciona($mues);
  16. }
  17.  
  18.  
  19. if ($_POST['enviar3'] == "Enviar")
  20. {  
  21.     $vehi_pate = $_POST['vehi_patente'];
  22.     $vehi_duen = $_POST['vehi_dueno'];
  23.     $vehi_esta = $_POST['vehi_estado'];
  24.     $vehi_obsv = $_POST['vehi_observaciones'];
  25.    
  26. /*  $sqlid = "SELECT vehi_patente from flotas.vehiculos WHERE vehi_patente LIKE '$mues'";
  27.     $resid = pg_query($sqlid);
  28.     $rowid = pg_num_rows($resid); */
  29.    
  30.             $sqlup3 ="update flotas.vehiculos set vehi_dueno = '$vehi_duen',
  31.                       vehi_estado = '$vehi_esta', vehi_observaciones = '$vehi_obsv'
  32.                       where vehi_id = '$mues'";
  33.             $regup3 = pg_query($sqlup3);   
  34.             echo "updatea";
  35.        
  36. }
__________________
- Ingeniero en Informática -
  #2 (permalink)  
Antiguo 08/04/2011, 15:35
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: Warning: pg_fetch_array()

¿porque dices que es un error? ¿te sale algún mensaje de error en concreto? ¿cual?
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #3 (permalink)  
Antiguo 11/04/2011, 07:04
Avatar de xamilo  
Fecha de Ingreso: febrero-2010
Mensajes: 120
Antigüedad: 14 años, 2 meses
Puntos: 1
Respuesta: Warning: pg_fetch_array()

el titulo lo dice....

pero aca lo repito

Warning: pg_fetch_array() expects parameter 1 to be resource, null given in

al comienzo del while del primer form
__________________
- Ingeniero en Informática -
  #4 (permalink)  
Antiguo 11/04/2011, 07:32
Avatar de masterpuppet
Software Craftsman
 
Fecha de Ingreso: enero-2008
Ubicación: Montevideo, Uruguay
Mensajes: 3.550
Antigüedad: 16 años, 3 meses
Puntos: 845
Respuesta: Warning: pg_fetch_array()

Que tal xamilo,

El error es bastante claro, $res6 no es un resource, en donde estas haciendo la query ?

Saludos.
__________________
http://es.phptherightway.com/
thats us riders :)
  #5 (permalink)  
Antiguo 11/04/2011, 07:51
Avatar de xamilo  
Fecha de Ingreso: febrero-2010
Mensajes: 120
Antigüedad: 14 años, 2 meses
Puntos: 1
Respuesta: Warning: pg_fetch_array()

aca

$sql6 = "select vehi_id, vehi_patente from flotas.vehiculos order by vehi_patente asc";
$res6 = pg_query($sql6);

require_once("query.php");
__________________
- Ingeniero en Informática -
  #6 (permalink)  
Antiguo 11/04/2011, 07:56
Avatar de masterpuppet
Software Craftsman
 
Fecha de Ingreso: enero-2008
Ubicación: Montevideo, Uruguay
Mensajes: 3.550
Antigüedad: 16 años, 3 meses
Puntos: 845
Respuesta: Warning: pg_fetch_array()

Bueno, debugea la query, algo asi:
Código PHP:
Ver original
  1. ...
  2. $sql6 = "select vehi_id, vehi_patente from flotas.vehiculos order by vehi_patente asc";
  3. $res6 = pg_query($sql6);
  4. if (false === $res6) {
  5.     echo pg_last_error();
  6.     exit;
  7. }
  8. ...
__________________
http://es.phptherightway.com/
thats us riders :)

Etiquetas: warning
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 12:11.