Foros del Web » Programando para Internet » PHP »

problema con codigo

Estas en el tema de problema con codigo en el foro de PHP en Foros del Web. Problema con el codigo. buen dia colegas, quiero saber si me pueden ayudar con este problema que tengo. micuenta.php Código PHP: <?   $result = ...
  #1 (permalink)  
Antiguo 06/08/2012, 09:14
Avatar de hulray  
Fecha de Ingreso: septiembre-2006
Mensajes: 630
Antigüedad: 17 años, 7 meses
Puntos: 3
problema con codigo

Problema con el codigo. buen dia colegas, quiero saber si me pueden ayudar con este problema que tengo.


micuenta.php
Código PHP:
<?
 
$result
=mysql_query ("SELECT * FROM users ORDER BY id desc"
$conexion);
echo
"<h3 align=\"center\">Mi Cuenta</h3>";  
echo 
"<table border=0 width=90%><tr>"
echo 
"<tr>";
echo 
"<td></td><td></td><td>Folio</td><td>Cuenta</td><td>Nombre Real</td><td>E-Mail</td><td>Cargo</td><td>Activa</td></tr>
</tr>"
;


while(
$row=mysql_fetch_row($result)){
echo 
"nick  '$nick'";
echo 
" row '$row'";
echo 
" result '$result'";


  echo 
"<tr>
    <td><td><a href=\"micuenta1.php?id_misusu=$row[0]\" target=\"_parent\"> <img src=\"../img/derec.gif\" width=16 height=16 alt=\"click\" border=0 align=left></a></td>
</td><td>$row[0]</td><td>$row[1]</td><td>$row[7]</td><td>$row[3]</td><td>$row[6]</td><td>$row[8]</td></tr>"
;
}
echo
"</table>
"
;
?>

micuenta1.php
Código PHP:
<?php

include('../config.php'); //incluimos el config.php que contiene los datos de la conexión a la db
  
srand((double)microtime()*1000000);

 
 
 
  if( isset(
$form_submit))

  {
//--> Datos

    
$r_id                trim(strip_tags($r_id));
    
$r_nombre            trim(strip_tags($r_nombre));
    
$r_pass               trim(strip_tags($r_pass));
    
$r_usuario           trim(strip_tags($r_usuario));
    
$r_mail                 trim(strip_tags($r_mail));
    
$r_cargo              trim(strip_tags($r_cargo));


//--> Datos 

    
$sql="select * from users where id='$row'";
    
$rs=mysql_query($sql);
    while(
$row=mysql_fetch_array($rs))
    
//$con_sql = "select * from users";
    //$ret     = db_query($con_sql);
    //$row     = db_fetch_array($ret);
    
$r_id      $row["id"];
    
$r_nombre  $row["nombre"];
    
$r_pass    $row["pass"];
    
$r_usuario    $row["nick"];
    
$r_mail    $row["email"];
    
$r_cargo    $row["rollo"];
    
$r_nick $session["nick"];


     
theme_draw_box_open"100%" );
     include_once( 
"micuenta2.php" );

     
theme_draw_box_close();
}else{
 
$sql="select * from users";
$rs=mysql_query($sql);
while(
$fila=mysql_fetch_array($rs))
{
echo
"<tr>";
echo
"<td>".$fila["id"]."</td>";
echo
"<td>".$fila["nombre"]."</td>";
echo
"<td>".$fila["pass"]."</td>";
echo
"<td>".$fila["mail"]."</td>";
echo
"<td>".$fila["rollo"]."</td>";
echo
"<td>".$fila["nick"]."</td>";
echo
"</tr>";
}

    include_once( 
"micuenta2.php" );

}

?>

micuenta2.php
Código PHP:
<form id="form1" name="form1" method="post" action="">
        <table width="200" border="0">
          <tr>
            <td>Nombre:</td>
            <td>
              <label>
                <input type="text" name="r_nombre" size="5" value="<? echo $r_nombre?>" />
                
              </label>            </td>
            <td>Password</td>
            <td><input type="text" name="r_pass" size="5" value="<? echo $r_pass?>" /></td>
          </tr>
          <tr>
            <td>Usuario:</td>
            <td><input type="text" name="r_usuario" size="5" value="<? echo $r_usuario?>" /></td>
            <td>e-mail</td>
            <td><input type="text" name="r_mail" size="5" value="<? echo $r_mail?>" /></td>
          </tr>
          <tr>
            <td>Cargo</td>
            <td><input type="text" name="r_cargo" size="5" value="<? echo $r_cargo?>" /></td>
            <td>&nbsp;</td>
            <td><input type="hidden" name="r_id" size="5" value="<? echo $r_id?>" /></td>
          </tr>
          <tr>
            <td colspan="4"><div align="center">
              <input type="submit" name="submit_datos" value="Guardar Cambios" />
            </div>
              <label>              </label>
              <label></label></td>
          </tr>
        </table>          
    </form>
es problema es que en micuenta.php me arroja todos los usuarios en una lista. Pero al pinchar un usuario no me arroja nada.
  #2 (permalink)  
Antiguo 06/08/2012, 09:20
Avatar de Eleazan  
Fecha de Ingreso: abril-2008
Ubicación: Ibiza
Mensajes: 1.879
Antigüedad: 16 años
Puntos: 326
Respuesta: problema con codigo

Código PHP:

if( isset($form_submit)) 
¿De dónde sacas eso?

Supongo que debería ser algo así:

Código PHP:

if( isset($_GET['id_misusu']) ) 
Con lo que entrarias en esa condición siempre y cuando pases el parámetro id_misusu por GET ;)


Código PHP:

//--> Datos 

    
$r_id                trim(strip_tags($r_id)); 
    
$r_nombre            trim(strip_tags($r_nombre)); 
    
$r_pass               trim(strip_tags($r_pass)); 
    
$r_usuario           trim(strip_tags($r_usuario)); 
    
$r_mail                 trim(strip_tags($r_mail)); 
    
$r_cargo              trim(strip_tags($r_cargo)); 
Están vacias esas variables (No existen), no sé pq las tratas ;)

Código PHP:
$sql="select * from users where id='$row'"
    
$rs=mysql_query($sql); 
    while(
$row=mysql_fetch_array($rs)) 
    
//$con_sql = "select * from users"; 
    //$ret     = db_query($con_sql); 
    //$row     = db_fetch_array($ret); 
    
$r_id      $row["id"]; 
    
$r_nombre  $row["nombre"]; 
    
$r_pass    $row["pass"]; 
    
$r_usuario    $row["nick"]; 
    
$r_mail    $row["email"]; 
    
$r_cargo    $row["rollo"]; 
    
$r_nick $session["nick"]; 
Supongo que aqui te falla la consulta sql... $row no existe. PHP no es mágico (o bien, nos falta código!). Supongo que será algo así:
Código PHP:
$sql="select * from users where id=".$_GET['id_misusu']; //Deberías "escaparla" 
__________________
>> Eleazan's Source
>> @Eleazan
  #3 (permalink)  
Antiguo 06/08/2012, 09:22
Avatar de hulray  
Fecha de Ingreso: septiembre-2006
Mensajes: 630
Antigüedad: 17 años, 7 meses
Puntos: 3
Respuesta: problema con codigo

muchas gracias por tu ayuda. voy a corregirlo
  #4 (permalink)  
Antiguo 06/08/2012, 09:48
Avatar de hulray  
Fecha de Ingreso: septiembre-2006
Mensajes: 630
Antigüedad: 17 años, 7 meses
Puntos: 3
Respuesta: problema con codigo

sos un crack, maestro, idolo!!!

muchas gracias... problema solucionado :)

Etiquetas: sql, usuarios
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 05:07.