Query does not work inside php [closed]

2

I made a query with a join to get information from the database, I tested it in mysql and it worked perfectly, the problem is that it does not work in php, not the execution error but the return is nullo, even if I change the I have used var_dump () to check for syntax error but do not have it.

$query="SELECT t1.* FROM tb_anuncio AS t1 JOIN tb_localizacao AS t2 ON t2.cd_localizacao = t1.cd_localizacao WHERE 1=1 AND t1.cd_categoria =".$categoria->getCd()." AND t2.nm_estado ='".$estado."' AND t2.nm_municipio ='".$municipio."' LIMIT ".$init.",".$max."";

$retorno = $this->conexao->query($query) or die(mysql_error());
                     while($anuncio = mysqli_fetch_assoc($retorno))
                     {
                         $anuncios[] = $anuncio;

                     }

var_dump:

"SELECT t1.* FROM tb_anuncio AS t1 JOIN tb_localizacao AS t2 ON t2.cd_localizacao = t1.cd_localizacao WHERE 1=1 AND t1.cd_categoria =1 AND t2.nm_estado ='AC' AND t2.nm_municipio ='Acrelândia' LIMIT 0,17"

Mysql

    
asked by anonymous 06.11.2018 / 03:37

2 answers

0

It tries to force the printing of the errors, maybe it gives error only it is not displayed due to the server settings, use this at the beginning of the code.

ini_set ('display_errors', 1);
ini_set ('display_startup_erros', 1);
error_reporting (E_ALL);

    
06.11.2018 / 17:24
0

I was able to solve the problem, even showing the contents of the variable with the correct values, the query lost the formatting when arriving at the bank on behalf of utf8, I used utf8_decode ($ municipalities) and it worked.

    
07.11.2018 / 15:35