Ver Mensaje Individual
  #1 (permalink)  
Antiguo 26/02/2009, 09:58
pauloco70
 
Fecha de Ingreso: febrero-2009
Mensajes: 5
Antigüedad: 15 años, 2 meses
Puntos: 0
Mysql_fetch_row inválido.

Buenos dias a todos, mi problema es el siguiente:
tengo un script que actualiza los datos de un usuario en MySQL, tomando un fichero de texto.
el script enq uestion está escrito en php, pero como el problema es con la funcion mysql_fetch_row, decidí postearlo en esta sección.
bueno, el código del programa es el siguiente:
Código:
   1.
      <html>
   2.
              <body>
   3.
                  <form action="" method="post">
   4.
                      <?php
   5.
                          # Get the reCAPTCHA library
   6.
                          require_once('recaptchalib.php');
   7.
       
   8.
                          //CAPTCHA, Anti Bots.
   9.
                          define('PUBLIC_KEY',  '6LffFgUAAAAAAFT4p5WS0p_aXtY5XpUOCxkuqXE6');
  10.
                          define('PRIVATE_KEY', '6LffFgUAAAAAAAbiilEH5JFNamUNA1ng8ZCd-zqi');
  11.
       
  12.
                         
  13.
                          $error = null;
  14.
       
  15.
                         
  16.
                          if ($_POST["recaptcha_response_field"]) {
  17.
                              $response = recaptcha_check_answer(
  18.
                                  PRIVATE_KEY, $_SERVER['REMOTE_ADDR'],
  19.
                                  $_POST['recaptcha_challenge_field'],
  20.
                                  $_POST['recaptcha_response_field']
  21.
                              );
  22.
      //SI EL CAPTCHA ANDA ENTONCES:
  23.
                              if ( $response->is_valid ) {
  24.
                                                      if(isset($_POST['username'],$_POST['password'])) {             
  25.
                                                      $user = $_POST['username'];
  26.
                                                      $pass = $_POST['password'];
  27.
                                                      //PONER UN  
  28.
                                                     
  29.
                                                      //Empieza conteo de variables
  30.
                                                      $archivo = file($user . ".usuario"); $lineas = count($archivo);
  31.
                                                      $ckills = $archivo[1];
  32.
                                                      $cmuertes = $archivo[2];
  33.
                                                      $kills = substr($ckills,6);
  34.
                                                      $deaths = substr($cmuertes,7);
  35.
                                                      require('configuracion.inc');
  36.
                                                      $c = mysql_connect("localhost","root","password")
  37.
                                                      or die("Error: " . mysql_error());
  38.
                                                      mysql_select_db("samp",$c)
  39.
                                                      or die("Error: " . mysql_error());
  40.
                                                      $sql1 = "SELECT user,pass WHERE user=$user";
  41.
                                                      $resultado1 = mysql_query($sql1,$c);
  42.
                                                      if(!resultado) {
  43.
                                                      print("Error!");
  44.
                                                      exit();
  45.
                                                      }                                              
  46.
                                                      $registro = mysql_fetch_row($resultado1);
  47.
                                                      $samppass = $registro[1];
  48.
                                                      if ($samppass == $pass) {
  49.
                                                      $sql2 = "UPDATE usuarios SET KILLS = '$kills', DEATHS = '$'deaths' WHERE user = $user";
  50.
                                                      $resultado = mysql_query($consulta,$c);
  51.
                                                      if($resultado) {
  52.
                                                      setcookie(Loguedo,$user);
  53.
                                                      header(stats.php);
  54.
                                             
  55.
                                                      }
  56.
                                                      } else { print("Las Contraseñas no coinciden."); }
  57.
                                                     
  58.
                                                      }
  59.
       
  60.
                                                     
  61.
                                                     
  62.
                                                     
  63.
                                                     
  64.
                                             
  65.
                                                     
  66.
                             
  67.
                              }
  68.
                              else {
  69.
                                                     
  70.
                                                     
  71.
                                                     
  72.
                                                     
  73.
                                                     
  74.
                                                     
  75.
                                                     
  76.
                                 //ERROR DEL CAPTCHA
  77.
                                  $error = $response->error;
  78.
                              }
  79.
                          }
  80.
                     
  81.
                          # Display the reCAPTCHA challenge. The first time
  82.
                          # through $error will be null.
  83.
       
  84.
                          echo recaptcha_get_html( PUBLIC_KEY, $error );
  85.
                      ?>
  86.
                      <br />
  87.
                     
  88.
                      Ususario: <input type="text" name="username" /><br />
  89.
                      Contraseña <input type="password" name="password" /><br />
  90.
                      <input type="submit" value="submit" />
  91.
                  </form>
  92.
              </body>
  93.
          </html>





y el error que me tira es:

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in C:\xampplite\htdocs\SAMP\blackzone\login.php on line 43

Gracias de antemano por su ayuda.