0
I did a search on this problem, found several with similar situation and, however, the problems were others. I have the following code where the query, if it is executed in the console, Mysql Workbench or phpmyadmin works perfectly.In this case, I checked the connection with the database and it is all right, because I modify the query to a very simple one, the script works correctly and brings the expected result. But with this query, the browser returns nothing, just a blank page. NOTE: Error messages are enabled in php.ini. Thank you!
<?php
require_once "conn.php";
$dbconnecta = mysqli_connect($server, $user, $pass);
if(!$dbconnecta) {
die("Not connected: ". mysqli_error());
}else{
mysqli_select_db($dbconnecta, $dba);
}
$query = "SELECT
n.nid,
a.field_dc_autores_nid,
n.title as titulo,
s.title as autor,
filename,
field_dublincore_source_value,
field_ano_da_publica_o_value,
art.name,
ed.name
FROM
node n
INNER JOIN
field_data_field_dc_autores a
ON a.entity_id = n.nid
AND n.type = 'conteudo'
INNER JOIN node s
ON a.field_dc_autores_nid = s.nid
AND s.type = 'autor'
INNER JOIN field_data_field_arquivo ar
ON ar.entity_id = n.nid
INNER JOIN file_managed
ON fid = field_arquivo_fid
INNER JOIN field_data_field_dublincore_source f
ON f.entity_id = n.nid
INNER JOIN ensp_producaocientifica.field_data_field_ano_da_publica_o ano
ON ano.entity_id = n.nid
INNER JOIN ensp_producaocientifica.field_data_field_grupo_da_producao_bibli
ON field_data_field_grupo_da_producao_bibli.entity_id = n.nid
INNER JOIN taxonomy_term_data art
ON tid = field_grupo_da_producao_bibli_tid
INNER JOIN field_data_field_dublincore_publisher pub
ON pub.entity_id = n.nid
INNER JOIN taxonomy_term_data ed
ON ed.tid = field_dublincore_publisher_tid
WHERE n.type = 'conteudo'
AND art.name like 'Artigos completos publicados em periódicos'
AND n.status = 1
AND n.nid = 369751
ORDER BY
nid DESC,
a.delta ASC
";
$dbresult = mysqli_query($dbconnecta, $query);
while ($row = mysqli_fetch_array($dbresult)) {
echo $row['titulo'] . "<br>";
echo $row['field_ano_da_publica_o_value'];
}
Add at the beginning of the script:
ini_set('display_errors', true); error_reporting(A_LL);
– rray
Some languages do not interpret the break line. You can add ""+"" for each break line:
$query = "SELECT
n.nid,"
+"a.field_dc_autores_nid,"
+"n.title as titulo,"
+"s.title as autor,"....
– EmanuelF
Great chance to be the accent in "journals", and its source has not been saved in the same encoding of DB. By the way, using like this way there makes no sense. Also, your code is not displaying SQL errors apparently.
– Bacco
Guys, thanks for answering. Well, come on: I put the part of:
– amarcanth
My previous comment has been cut. Still learning how to handle this system.... People, thank you for replying. Good, come on: @rray , I put the part of:
init_set('display_erros', true)
, etc and theerror_reporting
, but did not return anything. The page did not return anything, everything was empty. @Emanuelf , Add + for each line break. I even tried to put the query in a single line, but the result did not change. @Bacco , I modified the query to remove the accent, to stay"Artigos completos publicados em%"
and the result has not changed either...– amarcanth