Bluemercury Posted August 12, 2007 Share Posted August 12, 2007 Hi! im having the strangest behaviour regarding mysql+php,i have this script that decides what should be displayed in the screen: $id=$_SESSION["id"]; if($remoproc==2) { $query3= "SELECT * FROM acede where id_util='$id'"; //ANY query here without any foundings will result in the warning empty query $result=$bd->verificaSelects($conn,$query3); if($result) for($i=0;$i<mysqli_num_rows($result);$i++) { $row=mysqli_fetch_array($result); $id_doc[$i]=$row["did"]; } $query=''; for($i=1; $i<=sizeof($id_doc); $i++){ $a=$i-1; if($i==sizeof($id_doc)) $query .= "SELECT * FROM informacao_documento WHERE did='$id_doc[$a]' $condicao "; else $query .= "SELECT * FROM informacao_documento WHERE did='$id_doc[$a]' $condicao Union "; } $result=$bd->verificaSelects($conn,$query); }elseif($remoproc==1) { ?> <form name="form1" method="post" action="remove.php"><? $query2= "SELECT * FROM informacao_documento WHERE id_ut='$id'"; //HERE the queries will work fine even if they dont find anything $result=$bd->verificaSelects($conn,$query2); } This is the function of the database class that handles the queries: //funcao que trata das procuras na base de dados relativamente a integridade da query function verificaSelects($treta,$querie) { //executa query e verifica se nao dá erro echo $querie; $resultado = mysqli_query($treta,$querie); //or die('Erro, querie para procura falhou'); //ITS here where the warning is caused // echo $resultado; //Verificar se deu resultado diferente de zero //alterar para nao parar aplicacao if(mysqli_num_rows($resultado) == 0){ $test=mysqli_num_rows($resultado); echo "esta vazio $test"; } ///echo "Base dados está vazia!"; else { return $resultado; } I just find strange that the same querie can result in the Warning: mysqli_query() [function.mysqli-query]: Empty query warning in one place and not in the other..... Link to comment https://forums.phpfreaks.com/topic/64452-warning-empty-query/ Share on other sites More sharing options...
Fadion Posted August 13, 2007 Share Posted August 13, 2007 As ure getting the id from the session, have u used session_start()?? Link to comment https://forums.phpfreaks.com/topic/64452-warning-empty-query/#findComment-321969 Share on other sites More sharing options...
btherl Posted August 13, 2007 Share Posted August 13, 2007 That warning means your query ($querie) is empty. Check its value before passing it to verificaSelects() Link to comment https://forums.phpfreaks.com/topic/64452-warning-empty-query/#findComment-322024 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.