Foros del Web » Programando para Internet » PHP »

Problema al modificar registro

Estas en el tema de Problema al modificar registro en el foro de PHP en Foros del Web. wenas soy nuevo en esto de php, mi problema es que tengo un codigo para modificar registros en mi bd y muestra bien los datos ...
  #1 (permalink)  
Antiguo 02/09/2009, 06:35
 
Fecha de Ingreso: septiembre-2009
Ubicación: Cartagena
Mensajes: 11
Antigüedad: 14 años, 7 meses
Puntos: 0
Problema al modificar registro

wenas soy nuevo en esto de php, mi problema es que tengo un codigo para modificar registros en mi bd y muestra bien los datos pero cuando le doy a guardar no me modifica en mi bd. este es el codigo si alguien me puede ayudar se lo agradeceria mucho:

<?
include "conexionsantotomas.php";

if (!isset($accion)){
$result=mysql_query("SELECT * FROM archivo WHERE id=$id",
$conexion);
$row=mysql_fetch_row($result);
echo"<html>
<head><title>Actualizar datos de la base</title></head>
<body>
<form action=\"actualizar.php?accion=guardar\" method=\"POST\">
Nombre:<br>
<input type=\"text\" value=\"$row[1]\" name=\"nombre\"><br>
Direccion:<br>
<input type=\"text\" value=\"$row[2]\" name=\"direccion\"><br>
Codigo Postal:<br>
<input type=\"text\" value=\"$row[3]\" name=\"codigopostal\"><br>
Poblacion:<br>
<input type=\"text\" value=\"$row[4]\" name=\"Poblacion\"><br>
Telefono Fijo:<br>
<input type=\"text\" value=\"$row[5]\" name=\"Telefonofijo\"><br>
Telefono Movil:<br>
<input type=\"text\" value=\"$row[6]\" name=\"telefonomovil\"><br>
Fecha de Nacimiento:<br>
<input type=\"text\" value=\"$row[7]\" name=\"fechanacimiento\"><br>
Cargo Agrupacion:<br>
<input type=\"text\" value=\"$row[8]\" name=\"cargoagrupacion\"><br>
Cargo Cofradia:<br>
<input type=\"text\" value=\"$row[9]\" name=\"cargocofradia\"><br>
Fecha de Inscripcion:<br>
<input type=\"text\" value=\"$row[10]\" name=\"fechadeinscripcion\"><br>
Observaciones:<br>
<input type=\"text\" value=\"$row[11]\" name=\"observaciones\"><br>
<input type=\"hidden\" name=\"id\" value=\"$row[0]\">
<input type=\"submit\" value=\"Guardar\">
</form>
</body>
</html>";
}elseif($accion==guardar){
$result=mysql_query("UPDATE archivo SET nombre=$nombre,
direccion=$direccion, codigopostal=$codigopostal, poblacion=$poblacion, telefonofijo=$telefonofijo, telefonomovil=$telefonomovil, fechanacimiento=$fechanacimiento, cargoagrupacion=$cargocofradia, fechadeinscripcion=$fechadeinscripcion, observaciones=$observaciones WHERE id = $id",$conexion);
echo"
<html>
<body>
<h3>Los registros han sido actualizados</h3>
</body>
</html>";
}
include "cerrar_conexion.php";
?>
  #2 (permalink)  
Antiguo 02/09/2009, 06:45
 
Fecha de Ingreso: abril-2008
Mensajes: 453
Antigüedad: 16 años
Puntos: 16
Respuesta: Problema al modificar registro

Cita:
Iniciado por kalendula60 Ver Mensaje
wenas soy nuevo en esto de php, mi problema es que tengo un codigo para modificar registros en mi bd y muestra bien los datos pero cuando le doy a guardar no me modifica en mi bd. este es el codigo si alguien me puede ayudar se lo agradeceria mucho:

<?
include "conexionsantotomas.php";

if (!isset($accion)){
$result=mysql_query("SELECT * FROM archivo WHERE id=$id",
$conexion);
$row=mysql_fetch_row($result);
echo"<html>
<head><title>Actualizar datos de la base</title></head>
<body>
<form action=\"actualizar.php?accion=guardar\" method=\"POST\">
Nombre:<br>
<input type=\"text\" value=\"$row[1]\" name=\"nombre\"><br>
Direccion:<br>
<input type=\"text\" value=\"$row[2]\" name=\"direccion\"><br>
Codigo Postal:<br>
<input type=\"text\" value=\"$row[3]\" name=\"codigopostal\"><br>
Poblacion:<br>
<input type=\"text\" value=\"$row[4]\" name=\"Poblacion\"><br>
Telefono Fijo:<br>
<input type=\"text\" value=\"$row[5]\" name=\"Telefonofijo\"><br>
Telefono Movil:<br>
<input type=\"text\" value=\"$row[6]\" name=\"telefonomovil\"><br>
Fecha de Nacimiento:<br>
<input type=\"text\" value=\"$row[7]\" name=\"fechanacimiento\"><br>
Cargo Agrupacion:<br>
<input type=\"text\" value=\"$row[8]\" name=\"cargoagrupacion\"><br>
Cargo Cofradia:<br>
<input type=\"text\" value=\"$row[9]\" name=\"cargocofradia\"><br>
Fecha de Inscripcion:<br>
<input type=\"text\" value=\"$row[10]\" name=\"fechadeinscripcion\"><br>
Observaciones:<br>
<input type=\"text\" value=\"$row[11]\" name=\"observaciones\"><br>
<input type=\"hidden\" name=\"id\" value=\"$row[0]\">
<input type=\"submit\" value=\"Guardar\">
</form>
</body>
</html>";
}elseif($accion==guardar){
$result=mysql_query("UPDATE archivo SET nombre=$nombre,
direccion=$direccion, codigopostal=$codigopostal, poblacion=$poblacion, telefonofijo=$telefonofijo, telefonomovil=$telefonomovil, fechanacimiento=$fechanacimiento, cargoagrupacion=$cargocofradia, fechadeinscripcion=$fechadeinscripcion, observaciones=$observaciones WHERE id = $id",$conexion);
echo"
<html>
<body>
<h3>Los registros han sido actualizados</h3>
</body>
</html>";
}
include "cerrar_conexion.php";
?>

fijate en ponerle comillas a los valores string, observaciones="$observaciones" y pone lo siguiente debajo del query:

Código php:
Ver original
  1. if(!$result){
  2.           echo '<b style="font-size:20px">'.mysql_error().'</b>';
  3.   }
  #3 (permalink)  
Antiguo 02/09/2009, 06:57
 
Fecha de Ingreso: septiembre-2009
Ubicación: Cartagena
Mensajes: 11
Antigüedad: 14 años, 7 meses
Puntos: 0
no se que hago mal pero me sale
esto:
Parse error: syntax error, unexpected T_VARIABLE

muchas gracias samu22
ya lo he conseguido

muchas gracias ya esta hecho

Última edición por GatorV; 02/09/2009 a las 07:54
  #4 (permalink)  
Antiguo 02/09/2009, 07:11
 
Fecha de Ingreso: abril-2008
Mensajes: 453
Antigüedad: 16 años
Puntos: 16
Respuesta: Problema al modificar registro

buenisimo me alegro
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:02.