Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/10/2011, 12:57
PxuL
 
Fecha de Ingreso: mayo-2011
Mensajes: 20
Antigüedad: 13 años
Puntos: 1
Pregunta procedimiento almacenado de mysql llamarlo en php con lista

buenas el tengo un procedimiento almacenado en mysql y lo quiero llamarlo en php lo que pasa es que no me registrar los datos aqui les paso los codigos y el procedmiento almacenado espero que me puedan ayudar, si me lista en el combo lo que pasa es que no me registra.


procedimiento almacenado:

pa_insertar_cliente

Código PHP:
CREATE PROCEDURE pa_insertar_cliente 
(
  
IN  nombres     varchar(50),
  
IN  apellido    varchar(50),
  
IN  direccio    varchar(50),
  
IN  telefonos   char(8),
  
IN  dnis        char(8),
  
IN  emails      varchar(50),
  
IN  codciudads  int
)
BEGIN
  insert into clientes
(clientes.`clnombre`,
clientes.`apellidos`,
clientes.`direccion`,
clientes.`telefono`,
clientes.`DNI`,
clientes.`email`,
`
codciudad`)
values(nombres,apellido,direccio,telefonos,dnis,emails,codciudads);
END 
Codigo PHP:

Insertar_cliente.php

Código PHP:
<?php
//insertar cliente
$nombre $_POST['txtnombre'];
$apellidos $_POST['txtapellidos'];
$direccion $_POST['txtdireccion'];
$telefono $_POST['txttelefono'];
$dni $_POST['txtdni'];
$email $_POST['txtemail'];
$ciudad $_POST['lbciudad'];
$cn mysqli_connect("localhost","root","","restautante");
$rs mysqli_query($cn,"call pa_insertar_cliente('$nombre','$apellidos','$direccion','$telefono','$dni','$email',$ciudad)");
mysqli_close($cn);
header("location:index.php");
?>
registrar_cliente.php

Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php
$cn 
mysqli_connect("localhost","root","","restaurante");
$rs mysqli_query($cn,"call pa_listar_ciudad()");
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>.:: REGISTRAR CLIENTES ::.</title>
<style type="text/css">
<!--
a:link {
    text-decoration: none;
}
a:visited {
    text-decoration: none;
}
a:hover {
    text-decoration: none;
}
a:active {
    text-decoration: none;
}
body {
    background-image: url(Imagenes/fondo2.jpg);
    background-repeat: no-repeat;
}
.Estilo10 {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 12px;
    font-weight: bold;
}
-->
</style>
</head>

<body>
<form id="form1" name="form1" method="post" action="insertar_cliente.php">
      <table width="351" border="0" align="center">
        <tr bgcolor="#B6B04F">
          <th colspan="2" scope="col"><span class="Estilo16">Registrar Cliente</span></th>
        </tr>
        <tr bgcolor="#FFFFFF">
          <th width="120" scope="row"><div align="left"><span class="Estilo15">nombre</span></div></th>
          <td width="215"><label></label>
              <label></label>
              <input type="text" name="txtnombre" id="txtnombre" />          </td>
        </tr>
        <tr bgcolor="#FFFFFF">
          <th scope="row"><div align="left">apellidos</div></th>
          <td><label>
            <input type="text" name="txtapellidos" id="txtapellidos" />
            </label>          </td>
        </tr>
        <tr bgcolor="#FFFFFF">
          <th scope="row"><div align="left"><span class="Estilo15">Direccion:</span></div></th>
          <td><label>
            <input type="text" name="txtdireccion" id="txtdireccion" />
            </label>          </td>
        </tr>
        <tr bgcolor="#FFFFFF">
          <th scope="row"><div align="left"><span class="Estilo15">Telefono</span>:</div></th>
          <td><label>
            <input type="text" name="txttelefono" id="txttelefono" />
          </label>          </td>
        </tr>
        <tr bgcolor="#FFFFFF">
          <th scope="row"><div align="left"><span class="Estilo10">dni</span></div></th>
<td><label>
            <input type="text" name="txtdni" id="txtdni" />
          </label></td>
        </tr>
        <tr bgcolor="#FFFFFF">
          <th scope="row"><div align="left"><span class="Estilo15">E-mail:</span></div></th>
          <td><label>
            <input type="text" name="txtemail" id="txtemail" />
            </label>          </td>
        </tr>
        <tr bgcolor="#FFFFFF">
          <th class="Estilo15" scope="row"><div align="left">codciudad</div></th>
          <td><label>
            <select name="lbciudad" id="lbciudad">
             <?php
        
while($row mysqli_fetch_array($rs))
        echo 
"<option value=".$row['codciudad'].">".$row['desnombre']."</option>";
        
mysqli_free_result($rs);
        
mysql_close($cn);
        
?>
            </select>
          </label></td>
        </tr>
        <tr bgcolor="#FFFFFF">
          <th scope="row">&nbsp;</th>
          <td><input type="submit" name="btnregistrar" id="btnregistrar" value="Registrar" /></td>
        </tr>
      </table>
</form>    </th>
  </tr>
  <tr bgcolor="#B6B04F">
    <th scope="row">&nbsp;</th>
  </tr>
</table>
</body>
</html>

Última edición por PxuL; 09/10/2011 a las 13:03 Razón: procedimiento,php,mysql