Foros del Web » Programando para Internet » PHP »

Problema registro de datos

Estas en el tema de Problema registro de datos en el foro de PHP en Foros del Web. Estimados estoy generando una consulta de datos y posteriormente guardo esos registros pero me genera el siguiente error .. por favor ayudar Notice: Undefined variable: ...
  #1 (permalink)  
Antiguo 26/05/2011, 13:37
Avatar de evolutionrgm  
Fecha de Ingreso: mayo-2011
Mensajes: 108
Antigüedad: 13 años
Puntos: 5
Información Problema registro de datos

Estimados estoy generando una consulta de datos y posteriormente guardo esos registros pero me genera el siguiente error .. por favor ayudar

Notice: Undefined variable: rut_grilla in C:\xampp\htdocs\intranet\usuarios\certantiguedad.p hp on line 198

Notice: Undefined variable: nom_grilla in C:\xampp\htdocs\intranet\usuarios\certantiguedad.p hp on line 198

Notice: Undefined variable: ape1_grilla in C:\xampp\htdocs\intranet\usuarios\certantiguedad.p hp on line 198

Notice: Undefined variable: ape2_grilla in C:\xampp\htdocs\intranet\usuarios\certantiguedad.p hp on line 198

Notice: Undefined variable: estable_grilla in C:\xampp\htdocs\intranet\usuarios\certantiguedad.p hp on line 198

Notice: Undefined variable: feching_grilla in C:\xampp\htdocs\intranet\usuarios\certantiguedad.p hp on line 198
ERROR al Registrar Certificado - 1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '; values ('',','',',','')' at line 1


el codigo que estoy realizando es el siguiente y dejare con rojo la linea que me marca error

<?php
if (!isset($_POST['envio'])){
// busco todod los registros
?>

<form method="post" action="certantiguedad.php">
<p>&nbsp;</p>
<table width="281" border="0" align="center">
<tr>
<td width="117">Ingrese Rut </td>
<td width="148"><label for="textfield"></label>
<input type="text" name="buscar"/></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="envio" value="Generar Consulta " /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
<p>&nbsp;</p>
</form>
<p class="title">&nbsp;</p>
<?php
}
else
{
include 'conexion.php';
//listo los datos del usuario
conectar();
$ruta = $_POST['buscar'];
$conecta="select * from usuarios where rut ='$ruta'";

//$conecta2="select * from certificado where id_certificado";
//$resultado2=mysql_query($conecta2);
$resultado =mysql_query($conecta);
$cuenta=mysql_num_rows ($resultado);
$no="<br><br> Coincidencias $cuenta ... No se a encontrado Usuario con ese Nro de Rut .. <a href='certantiguedad.php'> Regresar </a>";
$si="<br><br> $cuenta Resultado Coincide con su Búsqueda <a href ='certantiguedad.php'> Regresar </a><br><br>";

if ($cuenta > 0)
{
while ($myrow =mysql_fetch_array($resultado))
{


$rut_grilla=$myrow['rut'];
$nom_grilla=$myrow['nom'];
$ape1_grilla=$myrow['apellido1'];
$ape2_grilla=$myrow['apellido2'];
$estable_grilla=$myrow['establecimiento'];
$feching_grilla=$myrow['fech_ingreso'];


//armo link de generacion de listado del documento
$listar ="certificado.php?id_certificado=$myrow[rut]";
echo $si;
?>
<table border="1" width="100%" cellpadding="4" cellspacing="0" >
<tr>
<td width="61%" bgcolor="#FFFF00">Rut :<?php echo $myrow['rut'];?></td>
</tr>
<tr>
<td width="61%"> Nombre : <?php echo $myrow['nom'];?></td>
</tr>
<tr>
<td width="61%"> Apellido Paterno : <?php echo $myrow['apellido1'];?></td>
</tr>
<tr>
<td width="61%"> Apellido Materno : <?php echo $myrow['apellido2'];?></td>
</tr>
<tr>
<td width="61%"> Establecimiento : <?php echo $myrow['establecimiento'];?></td>
</tr>
<tr>
<td width="61%"> Fecha de Ingreso : <?php echo $myrow['fech_ingreso'];?></td>
</tr>
<tr>
<td>Tipo de contrato</td>
<td width="39%"><label>
<select name="tipo_contrato">
<option value="0">
Seleccione Tipo de Contrato
</option>


<?php


conectar();

$consul=mysql_query("SELECT * FROM tipo_contrato");


while($registro=mysql_fetch_row($consul))
{ if(($registro[1])==$estable){
echo "<option value='$registro[1]' selected>$registro[0] $registro[1] </option>";

}
else{
echo "<option value='$registro[1]'> $registro[0] $registro[1] </option>";
}
}

echo "</select>";

?>

<td width="61%"bgcolor="#00FF00"><a href="<?php echo $listar;?>">Emitir Documento PDF<a>
</table>
<?php
desconectar();//end while
}
}
else
{
echo $no;
}
}
?>
<?php
//Genero la recoleccion de datos
//$id_grilla=$myrow['rut'];
include 'conexion.php';
//armo la recolectacion de archivos
conectar();
$sql ="insert into certificado (id_certificado,rut,nombre,apellido1,apellido2,est ablecimi,fechingre);
values ('$rut_grilla','$nom_grilla,'$ape1_grilla','$ape2_ grilla,'$estable_grilla,'$feching_grilla')";
$result =mysql_query($sql);
if (!mysql_error())
{
echo "El Certificado fue Registrado exitosamente<br>";
}
else
{
echo "ERROR al Registrar Certificado - ". mysql_errno() .":". mysql_error()."<br>";
}

?>
  #2 (permalink)  
Antiguo 26/05/2011, 14:20
Avatar de memoadian
Colaborador
 
Fecha de Ingreso: junio-2009
Ubicación: <?php echo 'México'?>
Mensajes: 3.696
Antigüedad: 14 años, 10 meses
Puntos: 641
Respuesta: Problema registro de datos

En la linea 58 faltan unas comillas simples en $myrow[rut]

con respecto a las variables indefinidas prueba poniendo bien las comillas:

Código PHP:
Ver original
  1. <?php
  2. $sql ="insert into certificado (id_certificado,rut,nombre,apellido1,apellido2,est ablecimi,fechingre)
  3. values ('".$rut_grilla."','".$nom_grilla."','".$ape1_grilla."','".$ape2_ grilla."','".$estable_grilla."','".$feching_grilla."')";
  4. ?>
  #3 (permalink)  
Antiguo 26/05/2011, 14:52
Avatar de evolutionrgm  
Fecha de Ingreso: mayo-2011
Mensajes: 108
Antigüedad: 13 años
Puntos: 5
Respuesta: Problema registro de datos

trato de esta otra forma con un boton y nada alguien me puede dar una ayuda por favor

Cita:
<?php
if (!isset($_POST['envio'])){
// busco todod los registros
?>

<form method="post" action="certantiguedad.php">
<p>&nbsp;</p>
<table width="281" border="0" align="center">
<tr>
<td width="117">Ingrese Rut </td>
<td width="148"><label for="textfield"></label>
<input type="text" name="buscar"/></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="envio" value="Generar Consulta " /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
<p>&nbsp;</p>
</form>
<p class="title">&nbsp;</p>
<?php
}
else
{
include 'conexion.php';
$boton="";

//listo los datos del usuario
conectar();
$ruta = $_POST['buscar'];
$conecta="select * from usuarios where rut ='$ruta'";

//$conecta2="select * from certificado where id_certificado";
//$resultado2=mysql_query($conecta2);
$resultado =mysql_query($conecta);
$cuenta=mysql_num_rows ($resultado);
$no="<br><br> Coincidencias $cuenta ... No se a encontrado Usuario con ese Nro de Rut .. <a href='certantiguedad.php'> Regresar </a>";
$si="<br><br> $cuenta Resultado Coincide con su Búsqueda <a href ='certantiguedad.php'> Regresar </a><br><br>";

if ($cuenta > 0){
$boton="<input type='submit' name='ingresa' id='button' value='Generar Reporte' />";
while ($myrow =mysql_fetch_array($resultado))
{

//armo la recolectacion de archivos
//armo link de generacion de listado del documento
$listar ="certificado.php?id_certificado=$myrow[rut]";
echo $si;
?>
<table border="1" width="100%" cellpadding="4" cellspacing="0" >
<tr>
<td width="50%" bgcolor="#FFFF00">Rut :<?php echo $myrow['rut'];?></td>
</tr>
<tr>
<td width="50%"> Nombre : <?php echo $myrow['nom'];?></td>
</tr>
<tr>
<td width="50%"> Apellido Paterno : <?php echo $myrow['apellido1'];?></td>
</tr>
<tr>
<td width="50%"> Apellido Materno : <?php echo $myrow['apellido2'];?></td>
</tr>
<tr>
<td width="50%"> Establecimiento : <?php echo $myrow['establecimiento'];?></td>
</tr>
<tr>
<td width="50%"> Fecha de Ingreso : <?php echo $myrow['fech_ingreso'];?></td>
</tr>
<tr>
<td height="92">Tipo de contrato</td>
<td width="50%"><label>
<select name="tipo_contrato">
<option value="0">
Seleccione Tipo de Contrato
</option>


<?php


conectar();

$consul=mysql_query("SELECT * FROM tipo_contrato");


while($registro=mysql_fetch_row($consul))
{ if(($registro[1])==$estable){
echo "<option value='$registro[1]' selected>$registro[0] $registro[1] </option>";

}
else{
echo "<option value='$registro[1]'> $registro[0] $registro[1] </option>";
}
}

echo "</select>";

?>

</table>
<?php
// aqui va segundo boton //
echo $boton;

desconectar();//end while
}
}
else
{
echo $no;
}
}
?>

<?php

if(isset($_POST['ingresa']))
{
$rut_grilla=$myrow['rut'];
$nom_grilla=$myrow['nom'];
$ape1_grilla=$myrow['apellido1'];
$ape2_grilla=$myrow['apellido2'];
$estable_grilla=$myrow['establecimiento'];
$feching_grilla=$myrow['fech_ingreso'];

$sql ="insert into certificado (id_certificado,rut,nombre,apellido1,apellido2,est ablecimi,fechingre)";
$sql =" values ('$rut_grilla','$nom_grilla,'$ape1_grilla','$ape2_ grilla,'$estable_grilla,'$feching_grilla')";
$result =mysql_query($sql);
if (!mysql_error())
{
echo "El Certificado fue Registrado exitosamente<br>";
}
else
{
echo "ERROR al Registrar Certificado - ". mysql_errno() .":". mysql_error()."<br>";
}
}
?>[/PHP]
  #4 (permalink)  
Antiguo 26/05/2011, 14:54
Avatar de memoadian
Colaborador
 
Fecha de Ingreso: junio-2009
Ubicación: <?php echo 'México'?>
Mensajes: 3.696
Antigüedad: 14 años, 10 meses
Puntos: 641
Respuesta: Problema registro de datos

leiste mi respuesta?

tienes mal encapsulados tus values, por ejemplo tienes 'nom_grilla, '

eso esta fatal, lee lo que uno te dice.

Etiquetas: registro
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 06:08.