Foros del Web » Programando para Internet » PHP »

No Actualiza ;S

Estas en el tema de No Actualiza ;S en el foro de PHP en Foros del Web. editar.php Código PHP: <html> <title> Pokedex Editar </title> <body background="Imagen/fondo.jpg">           <head> <center> <b> <font size = +7 color = edeb48> Modificar tus Datos y Pokemon </font> </b> </center> </head>      <br>      <center> <img src = "Imagen/pintor.png"> </center><br>            <form action="editar.php" method="post">                <font size = +1 color = white > <b> >Selecciona tu id: <input type="int" name="id" value="" /> </b> </font> <br>         <br>         <font size = +1 color = white > <b> >Modificar Nombre: <input type="text" name="nombre" value="" /> </b> </font> <br>         <br>         <font size = +1 color = white > <b> >Modificar Pokemon: <input type="text" name="pokemon" value="" /> </b> </font> <br>         <br>         <font size = +1 color = white > <b> >Modificar Tipo1: <input type="text" name="tipo1" value="" /> </b> </font> <br>         <br>         <font size = +1 color = white > <b> >Modificar Tipo2: <input type="text" name="tipo2" value="" /> </b> </font> <br>         <br>         <font size = +1 color = white > <b> >Modificar Fecha(aaaa-mm-dd): <input type="text" name="fecha" value="" /> </b> </font> <br>         <input type="submit" name="boton" value="Aceptar" /> ...
  #1 (permalink)  
Antiguo 17/10/2010, 11:02
 
Fecha de Ingreso: octubre-2010
Mensajes: 4
Antigüedad: 16 años
Puntos: 0
Pregunta No Actualiza ;S

editar.php
Código PHP:
<html>
<title> Pokedex Editar </title>
<body background="Imagen/fondo.jpg">
    
     <head> <center> <b> <font size = +7 color = edeb48> Modificar tus Datos y Pokemon </font> </b> </center> </head>
     <br>
     <center> <img src = "Imagen/pintor.png"> </center><br>
     
     <form action="editar.php" method="post">
      
        <font size = +1 color = white > <b> >Selecciona tu id: <input type="int" name="id" value="" /> </b> </font> <br>
        <br>
        <font size = +1 color = white > <b> >Modificar Nombre: <input type="text" name="nombre" value="" /> </b> </font> <br>
        <br>
        <font size = +1 color = white > <b> >Modificar Pokemon: <input type="text" name="pokemon" value="" /> </b> </font> <br>
        <br>
        <font size = +1 color = white > <b> >Modificar Tipo1: <input type="text" name="tipo1" value="" /> </b> </font> <br>
        <br>
        <font size = +1 color = white > <b> >Modificar Tipo2: <input type="text" name="tipo2" value="" /> </b> </font> <br>
        <br>
        <font size = +1 color = white > <b> >Modificar Fecha(aaaa-mm-dd): <input type="text" name="fecha" value="" /> </b> </font> <br>
        <input type="submit" name="boton" value="Aceptar" />
     </form>
     <br>
        <br>
            <br>
                <br>
</form>
    </body>
 
<?php

$imagen 
= '<img src = "Imagen/Bulbasaur.png">';
$imagen2 = '<img src = "Imagen/Charmander.png">';
$imagen3 = '<img src = "Imagen/Ralts.png">';
$imagen4 = '<img src = "Imagen/Pichu.png">';

$texto1 = '<b><font size = +1 color = 2e8b39> Alta tu nombre y Pokemon <A HREF="http://localhost/altas.php">aqui</a> </font></b>';
$texto2 = '<b><font size = +1 color = d4882f> Da de baja tu nombre y Pokemon <A HREF="http://localhost/bajas.php">aqui</a></font></b>';
$texto3 = '<b><font size = +1 color = white> Home <A HREF="http://localhost/pokedex.php">aqui</a></font></b>';
$texto4 = '<b><font size = +1 color = ebe658> Consulta los Pokemon existentes <A HREF="http://localhost/consulta.php">aqui</a></font></b>';

echo 
$imagen;
echo 
$texto1;
echo 
" ";echo " ";
echo 
$imagen2;
echo 
$texto2;
echo 
" ";echo " ";
echo 
$imagen3;
echo 
$texto3;
echo 
" ";echo " ";
echo 
$imagen4;
echo 
$texto4;

?>

</html>
editar2.php

Código PHP:
<?php


     $conexion 
= mysql_connect("localhost","root","");
     
mysql_select_db("andres", $conexion);
     
     
     
$arg1 = $_POST['id'];
     
$arg2 = $_POST['nombre'];
     
$arg3 = $_POST['pokemon'];
     
$arg4 = $_POST['tipo1'];
     
$arg5 = $_POST['tipo2'];
     
$arg6 = $_POST['fecha'];
  
     
     
$argumentoquery = "update registros set nombre = " . $arg2 . ", where id = " . $arg1 . ";" ;
     
$consulta = mysql_query($argumentoquery, $conexion);
   
     
$argumentoquery2 = "update registros set pokemon = ". $arg2 . " where id = " . $arg1 . ";" ;
     
$consulta2 = mysql_query($argumentoquery2, $conexion);
     
     
$argumentoquery3 = "update registros set tipo1 = ". $arg2 . " where id = " . $arg1 . ";" ;
     
$consulta3 = mysql_query($argumentoquery3, $conexion);
     
     
$argumentoquery4 = "update registros set tipo2 = ". $arg2 . " where id = " . $arg1 . ";" ;
     
$consulta4 = mysql_query($argumentoquery4, $conexion);
     
     
$argumentoquery5 = "update registros set fecha = ". $arg2 . " where id = " . $arg1 . ";" ;
     
$consulta5 = mysql_query($argumentoquery5, $conexion);

     
header("Location: editar.php");

?>
Espero puedan decirme que es lo que pasa que no actualiza
  #2 (permalink)  
Antiguo 17/10/2010, 11:10
Avatar de spider_boy  
Fecha de Ingreso: diciembre-2003
Ubicación: Chile
Mensajes: 1.855
Antigüedad: 22 años, 9 meses
Puntos: 89
Respuesta: No Actualiza ;S

Lo primero, siempre depurar tus consultas con mysql_error(), segundo, creo que dentro de las queries, te están sobrando unos ";", y por último, todas esos updates, los puedes hacer en uno solo.
__________________
Nunca te olvidaré mi negra hermosa. Te extraño demasiado.
  #3 (permalink)  
Antiguo 17/10/2010, 11:38
 
Fecha de Ingreso: octubre-2010
Mensajes: 4
Antigüedad: 16 años
Puntos: 0
Respuesta: No Actualiza ;S

Código PHP:
[B][I][U]editar.php[/U][/I][/B]
<?php


     $conexion 
= mysql_connect("localhost","root","");
     
mysql_select_db("andres", $conexion);
     
     
     
$arg1 = $_POST['id'];
     
$arg2 = $_POST['nombre'];
     
$arg3 = $_POST['pokemon'];
     
$arg4 = $_POST['tipo1'];
     
$arg5 = $_POST['tipo2'];
     
$arg6 = $_POST['fecha'];
     
     
$argumentoquery = "update registros set nombre = ". $arg2 . "where id = " . $arg1 . ;
     
$consulta = mysql_query($argumentoquery, $conexion);
   
     
$argumentoquery2 = "update registros set pokemon = ". $arg3 . "where id = " . $arg1 . ;
     
$consulta2 = mysql_query($argumentoquery2, $conexion);
     
     
$argumentoquery3 = "update registros set tipo1 = ". $arg4 . "where id = " . $arg1 . ;
     
$consulta3 = mysql_query($argumentoquery3, $conexion);
     
     
$argumentoquery4 = "update registros set tipo2 = ". $arg5 . "where id = " . $arg1 . ;
     
$consulta4 = mysql_query($argumentoquery4, $conexion);
     
     
$argumentoquery5 = "update registros set fecha = ". $arg6 . "where id = " . $arg1 . ;
     
$consulta5 = mysql_query($argumentoquery5, $conexion);

     
header("Location: editar.php");

?>
ya lo corregi lo mejor qu epude pero la verdad es que no entiendo proque no funciona D: ojala alguien sea mas claro en lo que me falta
  #4 (permalink)  
Antiguo 17/10/2010, 11:51
Avatar de spider_boy  
Fecha de Ingreso: diciembre-2003
Ubicación: Chile
Mensajes: 1.855
Antigüedad: 22 años, 9 meses
Puntos: 89
Respuesta: No Actualiza ;S

Ok, quizá te hace falta leer un poco más de sql y php.

Ejemplo :

Código PHP:
Ver original
  1. $argumentoquery = "update registros set nombre = '".$valornombre."', pokemon = '".$valorpokemon."', tipo1='".$valortipo1."', tipo2='".$valortipo2."', fecha = '". $valorfecha . "' where id = '" . $valorid."'";
  2. $consulta = mysql_query($argumentoquery, $conexion);

Así te ahorras 5 Updates.
__________________
Nunca te olvidaré mi negra hermosa. Te extraño demasiado.
  #5 (permalink)  
Antiguo 17/10/2010, 12:23
 
Fecha de Ingreso: octubre-2010
Mensajes: 4
Antigüedad: 16 años
Puntos: 0
Respuesta: No Actualiza ;S

Código PHP:
<?php


     $conexion 
= mysql_connect("localhost","root","");
     
mysql_select_db("andres", $conexion);
     
     
     
$valorid = $_POST['id'];
     
$valornombre = $_POST['nombre'];
     
$valorpokemon = $_POST['pokemon'];
     
$valortipo1 = $_POST['tipo1'];
     
$valortipo2 = $_POST['tipo2'];
     
$valorfecha = $_POST['fecha'];
  
     
    
$argumentoquery = "update registros set nombre = '".$valornombre."', pokemon = '".$valorpokemon."', tipo1='".$valortipo1."', tipo2='".$valortipo2."', fecha = '". $valorfecha . "' where id = '" . $valorid."'";
    
$consulta = mysql_query($argumentoquery, $conexion);

     
header("Location: editar.php");

?>
es de esta forma como me decias que tendria que quedar?
ya que lo e corrido de esta manera junto con la pagina editar.php que puse al principio y la verdad eque no funciona ;S
  #6 (permalink)  
Antiguo 17/10/2010, 14:17
Avatar de spider_boy  
Fecha de Ingreso: diciembre-2003
Ubicación: Chile
Mensajes: 1.855
Antigüedad: 22 años, 9 meses
Puntos: 89
Respuesta: No Actualiza ;S

A ver, veamos...

Primero, antes de tratar de ejecutar la actualización, imprime la cadena, de esta forma :

Código PHP:
Ver original
  1. $argumentoquery = "update registros set nombre = '".$valornombre."', pokemon = '".$valorpokemon."', tipo1='".$valortipo1."', tipo2='".$valortipo2."', fecha = '". $valorfecha . "' where id = '" . $valorid."'";
  2.  
  3. echo $argumentoquery;

Así verás como está formada el string y si falta algún valor, si algo no llega, si algo que llega no corresponde, etc.

Por otro lado, depura tu consulta, para lo cual se creó mysql_error() :

Código PHP:
Ver original
  1. $argumentoquery = "update registros set nombre = '".$valornombre."', pokemon = '".$valorpokemon."', tipo1='".$valortipo1."', tipo2='".$valortipo2."', fecha = '". $valorfecha . "' where id = '" . $valorid."'";
  2. $consulta = mysql_query($argumentoquery, $conexion) or die(mysql_error());

Si muestra algún error, pégalo acá y vemos que pasa.
__________________
Nunca te olvidaré mi negra hermosa. Te extraño demasiado.
  #7 (permalink)  
Antiguo 17/10/2010, 14:39
 
Fecha de Ingreso: octubre-2010
Mensajes: 4
Antigüedad: 16 años
Puntos: 0
Respuesta: No Actualiza ;S

;S no funka creo que tendre que presentar mi trabajo de esta manera porlomenos la paguina que ise de insertar datoos , consultar y eliminar funcionan de marabilla solo este no pude

lo peor del caso es qe no me tira error solo que no funciona
  #8 (permalink)  
Antiguo 17/10/2010, 14:45
Avatar de carlos_belisario
Colaborador
 
Fecha de Ingreso: abril-2010
Ubicación: Venezuela Maracay Aragua
Mensajes: 3.156
Antigüedad: 16 años, 5 meses
Puntos: 461
Respuesta: No Actualiza ;S

Cita:
Iniciado por spider_boy Ver Mensaje
A ver, veamos...

Primero, antes de tratar de ejecutar la actualización, imprime la cadena, de esta forma :
hiciste esto?? como te la muestra?? copiala desde el navegador y pegala en tu PHPMYADMIN o en el cliente mysql que uses y ve si asi si actualiza, otra cosa coloca esto al principio a ver si tienes desabilitado el envio de errores
Código PHP:
error_reporting(E_ALL);
ini_set("display_errors", 1); 
saludos
__________________
aprende d tus errores e incrementa tu conocimientos
it's not a bug, it's an undocumented feature By @David
php the right way

Etiquetas: actualizar
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 17:40.