Page 1 of 1

Dying - die(). Please, help me.

Posted: Mon Mar 16, 2009 9:06 am
by granite
Hey, men, I need help.

The code below should verify how many rows are in the query, or print an error message...
Instead, the script just stops and doesn't show any error.
Anyway, I know there's some kind of mysql error, but I have no ideia of what it is. Why isn't die() returning the error? Something related to the host, perhaps? php.ini?

Code: Select all

function VerificarUsuario($Login_,$Senha_){
            $Query = "SELECT * FROM usuario WHERE usu_login='".$Login_."' AND usu_senha='".$Senha_."' AND usu_status=1";
            $Consulta = mysql_query($Query);
            echo "Consulta";
            $NLinhas =  mysql_num_rows($Consulta) or die(mysql_error());
            echo "NLinhas";
            if($NLinhas>0){
                return true;
            }else{
                return false;
            }
        }
Did you notice those 'echos'? The first one runs, printing 'Consulta', but the second one doesn't.

Thanks in advance.

Re: Dying - die(). Please, help me.

Posted: Mon Mar 16, 2009 9:29 am
by mattpointblank
Try running the 'or die(mysql_error());' part after you use mysql_query, rather than mysql_num_rows. The error is probably caused by your query.

Re: Dying - die(). Please, help me.

Posted: Mon Mar 16, 2009 10:16 am
by granite
Hey, thanks!! :P

I've just solved the problem.