Dying - die(). Please, help me.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
granite
Forum Commoner
Posts: 44
Joined: Mon Feb 09, 2009 10:52 am

Dying - die(). Please, help me.

Post 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.
mattpointblank
Forum Contributor
Posts: 304
Joined: Tue Dec 23, 2008 6:29 am

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

Post 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.
granite
Forum Commoner
Posts: 44
Joined: Mon Feb 09, 2009 10:52 am

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

Post by granite »

Hey, thanks!! :P

I've just solved the problem.
Post Reply