Foros del Web » Programando para Internet » PHP »

Update MySql Php F1

Estas en el tema de Update MySql Php F1 en el foro de PHP en Foros del Web. Niños y Niñas Tengo un problemita, quiero actualizar campos en una base guardada, y lo malo es que no da errores pero no actuliza nada. ...
  #1 (permalink)  
Antiguo 14/12/2007, 08:23
Avatar de yetrus  
Fecha de Ingreso: marzo-2006
Mensajes: 252
Antigüedad: 18 años, 1 mes
Puntos: 0
Update MySql Php F1

Niños y Niñas

Tengo un problemita, quiero actualizar campos en una base guardada, y lo malo es que no da errores pero no actuliza nada. el codigo del Submit se ejecuta con el boton "modificar"

Please F1
Saludos y felices fiestas

Código:
CREATE TABLE `input_fw` (
  `in_id` int(11) NOT NULL auto_increment,
  `in_target` varchar(30) default NULL,
  `in_protocol` varchar(3) default NULL,
  `in_source` varchar(30) default NULL,
  `in_destiny` varchar(30) default NULL,
  `in_port` int(11) default NULL,
  PRIMARY KEY  (`in_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=17 ;
este el codigo PHP

Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin t&iacute;tulo</title>
</head>
<body>
<?
if (!$_POST['modificar'])
{
?>
<form>
<input type="hidden" name="sessid"  />
<input type="hidden" name="sis_usr" />
<? 
$link 
mysql_connect("localhost","root","123");
?>
<table border="0" align="center">
<tr>
<td>IP</td>
<td>Destino</td>
<td>Politica</td>
<td>Protocolo</td>
<td>Puerto</td>
</tr>
<?
mysql_select_db
("fw_elsan",$link);
$result mysql_query("select * from INPUT_FW",$link);
while (
$myrow mysql_fetch_array(($result)))
{
?>
    <tr>
    <td><input name="in_origen" type="text" value="<? echo $myrow["in_source"?>"</td>
    <td> <select name="in_destino" >
        <option >Seleccione</option>
        <option >Destino Uno</option>
        <option >Destino Dos</option>
        <option >Destino Tres</option>
        </select></td>
    <td><select name="in_politica" >
            <option >Seleccione</option>
        <option >Politica Uno</option>
        <option >Politica Dos</option>
        <option >Politica Tres</option>
        </select></td>
    <td><select name="in_protocolo" >
            <option >Seleccione</option>
        <option >Protocolo Uno</option>
        <option >Protocolo Dos</option>
        <option >Protocolo Tres</option>
        </select></td>
    <td><select name="in_puerto" >
            <option >Seleccione</option>
        <option >555</option>
        <option >666</option>
        <option >777</option>
        </select></td>
    <td><input type="submit" name="modificar" value ="Modificar" </td>
    <td><input type="button" name="borra" value ="Eliminar" </td>
<td></td><?
}    
?>
</tr></table></form>
<?
}
else 
{
    
$link mysql_connect("localhost","root","123");
            
mysql_select_db("fw_elsan",$link);
$sql "update INPUT_FW set in_protocol ='$in_protocolo',in_destiny = '$in_destino',in_target = '$in_politica',in_port = '$in_puerto' where in_source='$in_origen'";
    
mysql_query($sql,$link);
    
//echo "<meta http-equiv=refresh content=0;url=confirmacion.php? />";
}    
?>

</body>
</html>
  #2 (permalink)  
Antiguo 14/12/2007, 08:53
Usuario no validado
 
Fecha de Ingreso: julio-2003
Ubicación: <?="www.tuky.cl";?>
Mensajes: 132
Antigüedad: 20 años, 9 meses
Puntos: 4
Re: Update MySql Php F1

El problema que veo es que estas utilizando variables globales...

"update INPUT_FW set in_protocol ='$in_protocolo',in_destiny = '$in_destino',in_target = '$in_politica',in_port = '$in_puerto' where in_source='$in_origen'"

$in_protocolo debería ser $_POST['in_protocolo']... con las demás variables es lo mismo...

al final quedaría

"update INPUT_FW set in_protocol ='{$_POST['in_protocolo']}',in_destiny = '{$_POST['in_destino']}',in_target = '{$_POST['in_politica']}',in_port = '{$_POST['in_puerto']}' where in_source='{$_POST['in_origen']}'"

saludos,

tuky.-
  #3 (permalink)  
Antiguo 14/12/2007, 08:55
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Re: Update MySql Php F1

Tu problema puede ser que no tengas activada la directiva register_globals, por lo que en lugar de usar en la variable por decir $in_protocolo, la deberas de descargar de POST antes de usarla en tu SQL asi:
Código PHP:
$in_protocolo $_POST['in_protocolo']; 
Saludos.
  #4 (permalink)  
Antiguo 14/12/2007, 09:47
Avatar de yetrus  
Fecha de Ingreso: marzo-2006
Mensajes: 252
Antigüedad: 18 años, 1 mes
Puntos: 0
Re: Update MySql Php F1

Deje el query asi pero aun no hace nada en la Base
Gracias por la rapidez de respuestas !!

Código PHP:
$sql="update INPUT_FW set in_protocol ='{$_POST['in_protocolo']}',in_destiny ='{$_POST['in_destino']}',in_target ='{$_POST['in_politica']}',$in_port ='{$_POST['in_puerto']}' where in_source ='{$_POST['in_origen']}'"
  #5 (permalink)  
Antiguo 14/12/2007, 09:54
Usuario no validado
 
Fecha de Ingreso: julio-2003
Ubicación: <?="www.tuky.cl";?>
Mensajes: 132
Antigüedad: 20 años, 9 meses
Puntos: 4
Re: Update MySql Php F1

Intenta con este query:

"update INPUT_FW set in_protocol ='{$_POST['in_protocolo']}',in_destiny = '{$_POST['in_destino']}',in_target = '{$_POST['in_politica']}',in_port = {$_POST['in_puerto']} where in_source='{$_POST['in_origen']}'"

el problema puede ser en

in_port = '{$_POST['in_puerto']}'

Como in_port es numérico, su valor no se debería ingresar en comillas simples...

in_port = {$_POST['in_puerto']}

Última edición por tuky; 14/12/2007 a las 18:53
  #6 (permalink)  
Antiguo 14/12/2007, 10:12
Avatar de yetrus  
Fecha de Ingreso: marzo-2006
Mensajes: 252
Antigüedad: 18 años, 1 mes
Puntos: 0
Re: Update MySql Php F1

Asi lo deje pero nada, no hace cambios en la base
No cacho que puede ser, probe el query en por fuera y funciona pero no dentro del la web



Código PHP:
$sql="update INPUT_FW set in_protocol ='{$_POST['in_protocolo']}',in_destiny ='{$_POST['in_destino']}',in_target ='{$_POST['in_politica']}',$in_port ={$_POST['in_puerto']} where in_source ='{$_POST['in_origen']}'"
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 10:21.