Failed to hide array generation

Asked

Viewed 29 times

1

I have the following method of login in a Class php:

public function loginMembro( $_usuario, $_senha ) {

        $membro = null;

        $string = "SELECT idMembro, nome, apelido, bloqueado, usuario, senha
                   FROM membros
                   WHERE usuario ='" . $_usuario . "' AND senha ='" . $_senha . "' ";

        $registros = $this->conexao->query( $string );
        $quantasLinhas = $registros->num_rows;

        if ( $quantasLinhas > 0 ) {

            list( $idMembro, $nomeMembro, $apelido, $bloqueado, $usuario, $senha ) = $registros->fetch_row();

            $membro[ "idMembro" ] = $idMembro;
            $membro[ "nomeMembro" ] = $nomeMembro;
            $membro[ "apelido" ] = $apelido;
            $membro[ "bloqueado" ] = $bloqueado;
            $membro[ "usuario" ] = $usuario;
            $membro[ "senha" ] = $senha;

        }

        return $membro;

    }

On the UOL Host server, it works normal. However, locally, the array is NOT being generated.

Before the $Return member, I added a

pring_r($membro);

but shows nothing and does not give error in the inspector

I’m using Ajax:

// JavaScript Document
$(document).ready(function (e) {

    $("#logar").on("click", function () {

        usuario = $("#usuario").val();
        senha = $("#senha").val();

        if (usuario == "") {
            $(".resposta").html("Preencha usuário!");
            return false;
        }
        if (senha == "") {
            $(".resposta").html("Preencha senha!");
            return false;
        }

        $.ajax({
            url: "_scripts/_php/_validacoes/acesso.php",
            type: "POST",
            dataType: "json",
            data: {
                usuario: usuario,
                senha: senha
            },
            success: function (result) {
                if (result[1]["bloqueado"] == "bloqueado")
                    $(".resposta").html("Membro bloqueado!");
                else if (result[0] == "inexistente")
                    $(".resposta").html(result[1]);
                else
                    window.location = "celula.php";
            }
        });
    });
})

Obs.: Locally surrounds the string in the Mysql and returned. I wonder where I’m going wrong?

The HTML

<div class="logon">
    <div class="logos">
        <img src="_imgs/gceu.png"/>
    </div>
    <h2>Acessar</h2>
    <div class="pseudo">
        <img src="_imgs/user.png"/>
        <input type="text" name="usuario" id="usuario" placeholder="Usuário"/>
    </div>
    <div class="pseudo">
        <img src="_imgs/pass.png"/>
        <input type="password" name="senha" id="senha" placeholder="Senha"/>
    </div>
    <div class="lembra">
        <a href="recuperaSenha.php?recuperar">Esqueceu a senha?</a>
    </div>
    <button id="logar">LOGIN</button>
    <div class="resposta"></div>
</div>
  • Returned null, then did not enter the condition that defines $membro, soon $quantasLinhas should be zero. See in debug if the value is actually coming to zero.

  • yes, the $records->num_rows says it is 0. However, if we take the $string and launch it directly into Mysql it is giving 1 return

  • And what is the string value? It generated in PHP, var_dump($string) before executing the query

  • SELECT idMember, name, surname, blocked, user, password FROM members Where usuario ='caca' AND password ='74b87337454200d4d33f80c4663dc5e5'

  • Avascript and Jquery work, usually.

  • Then see if it is connected in the same database. If the same SQL produces different results, they must be in separate databases.

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.