Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/08/2011, 09:56
leo_star
 
Fecha de Ingreso: agosto-2011
Mensajes: 20
Antigüedad: 12 años, 8 meses
Puntos: 0
Pregunta pequeño problema con mi insert

Hola, tengo un pequeño problema con mi código. Intento simplemente hacer un INSERT a mi DB pero NO me resulta nose porque...

dejo el código del formulario llamado agregar_inventario.php

Código PHP:
<div class="article">
          <h2>Agregar Producto</h2>
         <?php
            $query
mysql_query('SELECT * FROM categorias ') or mysql_error();      
         
?>
          
          <table>
          <form action="validar_inventario.php" method="post">
              <tr><td>Nombre: </td><td><input name="nom_prod" type="text" id="nom_prod" size="20"  /></td> </tr>
              <tr><td>Precio: </td><td><input name="precio_prod" type="text" id="precio_prod" size="20"  /></td> </tr>
              
              <tr><td>Categor&iacute;a</td>
                <td>
                    <select value="categ_prod" name="categ_prod" id="categ_prod"> 
                        <option name="categ_prod" value="categ_prod" id="categ_prod">--Selecci&oacute;n--</option>
                            <?php 
                                
while($row mysql_fetch_array($query))
                                {                    
                                    echo 
"<option name='categ_prod' value='categ_prod' id='categ_prod'>" .$row['id_categ']. "</option>";
                                }   
                            
?>
                    </select>
                </td></tr>              
              <tr><td> </td><td><input type="submit"  value="Enviar Formulario " /></td></tr>
          </form>
          </table>
          <div class="clr"></div>
        </div>

Y bueno dejo el código de validar_inventario.php

Código PHP:
Ver original
  1. <?php
  2.             $nom_prod= $_POST['nom_prod'];
  3.             $precio_prod= $_POST['precio_prod'];
  4.             $categ_prod= $_POST['categ_prod'];
  5.  
  6.             $insert= mysql_query("INSERT INTO productos (nom_prod, precio_prod, categ_prod) VALUES ('$nom_prod','$precio_prod','$categ_prod')") or mysql_error();  
  7.  
  8. if(!$insert)
  9.             {
  10.                 echo 'Aparentemente tenemos problemas con el servidor.';
  11.  
  12.             }
  13.             else
  14.             {
  15.                 echo 'Se ha agregado su Producto sin problemas.';
  16.             }

verifique que fueran los campos correspondientes en el insert y todo perfecto....el problema esta yo creo con CATEG_PROD del formulario...
La consulta fetch_array de AGREGAR_INVENTARIO.php funciona perfectamente.

nose porque no me devuelve ningún error del mysql_error()...

Ojala me puedan ayudar!
Saludos!