Fatal Error Executing the Query

Asked

Viewed 25 times

0

I’m trying to do a while but I’m not getting it at all. It’s returning the error below:

Fatal error: Call to a Member Function query() on null in /home2/techlogu/public_html/index.php on line 697

My code is like this:

<?php

$sql = "SELECT 
agenda.id_curso, 
agenda.id_pessoa, 
cursos.img, 
pessoas.nick, 
cursos.nome_curso, 
pessoas.nome, 
cursos.conteudo
FROM pessoas 
INNER JOIN cursos 
INNER JOIN agenda ON cursos.id_curso = agenda.id_curso
AND pessoas.id_pessoa = agenda.id_pessoa
ORDER BY RAND()";  

// Executa a consulta OU mostra uma mensagem de erro
$resultado = $MySQLi->query($sql) OR trigger_error($MySQLi->error,  E_USER_ERROR);  // Essa é a linha 697 que tá dando erro fatal

while ($dataUser = $resultado->fetch_object()) {

$id_curso   = $dataUser->id_curso;
$id_pessoa  = $dataUser->id_pessoa;
$img        = $dataUser->img;
$nick       = $dataUser->nick;
$nome_curso = $dataUser->nome_curso;
$nome       = $dataUser->nome;
$conteudo   = $dataUser->conteudo;


?>
  • Good evening, friend you have already executed the query in a bank to see if the result ta ok? else, the writing $msqli your right ta? $result = $Mysqli->query($sql) look here: http://php.net/manual/en/mysqli.query.php I hope I helped you.

  • Hi Gilson. Thanks for the reply. I already ran the query in Phpmyadmin and it brought the result correctly. In the example that is on the link, there is no WHILE and from what I could compare in the example of the object oriented programming of the link that you gave me, it is correct to use $Mysqli->query($sql)

No answers

Browser other questions tagged

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