1
I have a SELECT
that generates results normally, but when I need to take the value of some column to use on another page it does not work.
Query code and attempt to pass the result from a column to a Session:
$login = $conexao->prepare("SELECT pessoa.id_login, pessoa.nome 'pnome',
pessoa.id_funcao, pessoa.id_pessoa 'idP', funcao.funcao
FROM login as login
JOIN pessoa as pessoa
on login.id_login = pessoa.id_login
OIN funcao as funcao
on pessoa.id_funcao = funcao.id_funcao
WHERE login.login= :user AND login.senha=:passwd LIMIT 1");
$login->bindParam(":user",$user, PDO::PARAM_STR);
$login->bindParam(":passwd",$passwd, PDO::PARAM_STR);
$login->execute();
if($login->rowCount()==1){
$login->fetch(PDO::FETCH_OBJ);
$this->setLogado($logado=true);
echo $_SESSION['user'] = $user;
echo "<br>".$_SESSION['passwd'] = $passwd;
echo "<br>".$_SESSION['id_pessoa'] = $login->id_pessoa;
echo "<br>".$_SESSION['abc'] = $login->pnome;
Error that PHP returns:
Note that the SESSIONS that had the value assigned by the variables $user
and $passwd
work normally.
if you assigned an alias (person.id_person 'idp') you should use it in the idp case, but I’m not sure, I believe the correct one would be (person.id_person as idp)
– Everton Neri