Foros del Web » Programando para Internet » PHP »

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in

Estas en el tema de Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in en el foro de PHP en Foros del Web. Buenas mi web tiene un sistema de verificacion de mail atraves de un hash pero me da este error: Warning: mysql_num_rows(): supplied argument is not ...
  #1 (permalink)  
Antiguo 15/02/2011, 21:19
 
Fecha de Ingreso: febrero-2011
Mensajes: 2
Antigüedad: 13 años, 2 meses
Puntos: 0
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in

Buenas mi web tiene un sistema de verificacion de mail atraves de un hash pero me da este error: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in email.php on line 16 y vengo apedir su ayuda ya que estoy empesando en el php y me interesa tener esto arreglado

por lo cual no se puede verificar el mail ya que deve tener la misma key que la del link.

Codigo:
Código PHP:
include('core.php');

if(isset(
$_GET['key'])){
    
$key FilterText($_GET['key']);
    
$keysql mysql_query("SELECT * FROM cms_verify WHERE key = '".$key."' LIMIT 1");
    if(
mysql_num_rows($keysql) > 0){
        
$keyrow mysql_fetch_assoc($keysql);
        
$email_verify_status mysql_fetch_assoc(mysql_query("SELECT email_verified FROM users WHERE id = 

'"
.$keyrow['id']."' LIMIT 1"));
        if(
$email_verify_status['email_verified'] == "-1"){ $reward false; }else{ $reward true; }
        
mysql_query("UPDATE users SET email_verified = '1', email = '".$keyrow['email']."' WHERE id = '".$keyrow['id']."' 

LIMIT 1"
);
        if(
$reward == true){ mysql_query("UPDATE users SET credits = credits + ".$email_verify_reward." WHERE id = 

'"
.$keyrow['id']."' LIMIT 1"); }
        if(
$reward == true){ mysql_query("INSERT INTO cms_transactions (userid,date,amount,descr) VALUES 

('"
.$keyrow['id']."','".$date_full."','".$email_verify_reward."','Verifying your email address')") or die(mysql_error()); }
        
mysql_query("DELETE FROM cms_verify WHERE key = '".$key."' LIMIT 1");
        
$sucess "1";
    }else{
        
$sucess "0";
    }
}else{
    
$sucess "0";
}
if(isset(
$_GET['remove'])){
    
$key FilterText($_GET['remove']);
    
$keysql mysql_query("SELECT * FROM cms_verify WHERE key = '".$key."' LIMIT 1");
    if(
mysql_num_rows($keysql) > 0){
        
$keyrow mysql_fetch_assoc($keysql);
        
mysql_query("UPDATE users SET email = '', email_verified = '-1', newsletter = '0' WHERE id = '".$keyrow['id']."' 

LIMIT 1"
);
        
mysql_query("DELETE FROM cms_verify WHERE key = '".$key."' LIMIT 1");
        
$sucess "2";
    }else{
        
$sucess "0";
    }
}

if(
$sucess == "1"){
?> 
el error se da en este if
Código PHP:
if(mysql_num_rows($keysql) > 0){ 
porfavor ayudenme.
  #2 (permalink)  
Antiguo 15/02/2011, 21:21
Avatar de Ronruby  
Fecha de Ingreso: julio-2008
Ubicación: 18°30'N, 69°59'W
Mensajes: 4.879
Antigüedad: 15 años, 9 meses
Puntos: 416
Respuesta: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result r

Depura tus consultas cuando uses mysql_query

Código PHP:
<?php

mysql_query
(/* consulta */) or die(mysql_error());

?>
  #3 (permalink)  
Antiguo 15/02/2011, 21:23
Avatar de carlos_belisario
Colaborador
 
Fecha de Ingreso: abril-2010
Ubicación: Venezuela Maracay Aragua
Mensajes: 3.156
Antigüedad: 14 años
Puntos: 461
Respuesta: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result r

Buenas cuando estas en la etapa de desarrollo siempre es bueno tener depuradas tus consultas, de esta manera sabras que error de sintaxis esta diciendote MySQL que tienes
Código PHP:
Ver original
  1. mysql_query("/*tu consulta */") or die(mysql_error());

saludos

edit me gano el amigo
__________________
aprende d tus errores e incrementa tu conocimientos
it's not a bug, it's an undocumented feature By @David
php the right way
  #4 (permalink)  
Antiguo 15/02/2011, 21:24
 
Fecha de Ingreso: febrero-2011
Mensajes: 2
Antigüedad: 13 años, 2 meses
Puntos: 0
Arreglado Gracias

Arreglado Gracias

Última edición por GatorV; 16/02/2011 a las 09:55
  #5 (permalink)  
Antiguo 16/02/2011, 04:44
Avatar de bNd170  
Fecha de Ingreso: agosto-2009
Ubicación: $this->setLocation('Valencia', 'Spain');
Mensajes: 365
Antigüedad: 14 años, 7 meses
Puntos: 13
Respuesta: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result r

Como consejo te sugiero que te crees una clase PHP para conexiones, asi solo tienes que declarar la clase en tu INDEX.php solo una vez y usar dicha clase cuantas veces quieras y unificar asi la manera de depurarlas (Si falla algo en la SQL que te muestre dicho error).

Te ahorraras mucho trabajo y tus proyectos quedarán mucho más limios.

Etiquetas: mysql, result, warning, argumentos
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 13:44.