Error: "mysql_num_rows() expects Parameter 1 to be Resource, null Given in Query was Empty"

Asked

Viewed 226 times

0

I am working on a document management system and I am trying to create reports that show me which documents were inserted daily, but I get the following error:

Warning: mysql_num_rows() expects Parameter 1 to be Resource, null Given in Query was Empty.

This is the page code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="../SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<link href="../SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
<script language="javascript">
   function reloj()
    {
     var tiempo=new Date();
     var hora=tiempo.getHours();
     var minuto=tiempo.getMinutes();
     var segundo=tiempo.getSeconds();
     var textohora=hora+":"+minuto+":"+segundo;
     var dia=tiempo.getDate();
     var mes=tiempo.getMonth()+1;
     var anis=tiempo.getYear();
     var textodias=dia +"/" +mes +"/" +anis;
     TextHora.value=textohora;
     TextDia.value=textodias;
     setTimeout("reloj()",500);

    }
    </script>
  <style type="text/css">
<!--
.style3 {font-size: 14px}
-->
  </style>
</head>

<body onload="reloj();">


<table width="949" border="1" align="center">
  <tr>
    <p><img src="../images5.jpg" width="675" height="247" /></p>
  </tr>
  <tr>
    <td><ul id="MenuBar1" class="MenuBarHorizontal">
      <li><a href="#" class="MenuBarItemSubmenu">Link</a>
        <ul>
         <li><a href="Pagina principal.php">Pagina principal</a></li>
          <li><a href="Tipos_Trabalhos_INSERIR.php">Tipo de Trabalho</a></li>
          <li><a href="SOLICITACAO_INSERIR.php">Solicita&ccedil;&atilde;o</a></li>
          <li><a href="Assistencia_INSERIR.php">Assist&ecirc;ncia</a></li>
        </ul>
      </li>
      <li><a href="#" class="MenuBarItemSubmenu">Modificar</a>
        <ul>
          <li><a href="Tipos_Trabalhos_MostrarTudo.php">Tipo de Trabalho</a></li>
          <li><a href="SOLICITACAO_MostrarTudo.php">Solicita&ccedil;&atilde;o</a></li>
        </ul>
      </li>
      <li><a href="#" class="MenuBarItemSubmenu">Eliminar</a>
        <ul>
          <li><a href="Tipos_Trabalhos_MostrarTudo.php">Tipo de Trabalho</a></li>
          <li><a href="SOLICITACAO_MostrarTudo.php">Solicita&ccedil;&atilde;o</a></li>
        </ul>
      </li>
      <li><a href="#" class="MenuBarItemSubmenu">Consultar</a>
        <ul>
          <li><a href="Consultar_Assistencias_Tecnicas.php">Assist&ecirc;cia Por Tipo de Trabalho</a></li>
        </ul>
      </li>
      <li><a href="#" class="MenuBarItemSubmenu">Relat&oacute;rio</a>
        <ul>
          <li><a href="Relatorio_Assistencias_Realizadas.php">Assist&ecirc;ncias </a></li>
        </ul>
      </li>
      <li><a href="#">Ajuda</a></li>
    </ul></td>
  </tr>
  <tr>
    <td>
          <p align="center" class="style3">FORÇAS ARMADAS ANGOLANAS </p>
 <p align="center" class="style3">COMANDO DO EXERCITO</p>
 <p align="center" class="style3">DIRECÇAO DE INFORMATICA</p>
 <hr>
<?php 
 $server='localhost';
   $DBName='arquivo';
   $senha='';
   $usuario='root';

 $con12=mysql_connect($server,$usuario,$senha);
 if($con12)
 {
   $selecionar=mysql_select_db($DBName,$con12);
  if($selecionar)
  {
      $consulta1="SELECT *d.id_documento,d.assunto,d.n_doc,d.id_ueo,d.id_tipodocumento,d.id_classificacao,d.n_folhas,d.n_exemplares,d.id_situacao,d.data,d.id_tipo_registo,d.executor FROM documento t,classificacao p,proveniencia o,situacao m,ueo d,documennto g,despacho e,tipo de registo a,tipo_de_documento s WHERE (p.iddocumento=g.iddocumento) and (d.id_situacao=o.id_situacao) and (d.id_ueo=m.id_ueo) and (d.idtipodocumento=a.idtipodocumento) and (d.idclassificacao=t.idclassificacao) and (d.id_situacao=o.id_situacao) and (t.descricao like '$COMBO')";
     $resultado1=mysql_query($consulta,$con12);

     echo "<table border='1' align='center' width='900' bgcolor='#FFFFFF'> ";
        echo "<tr>"; 

      echo "<table border='1' align='center' width='900' bgcolor='#FFFFFF'> ";
      echo "<tr>"; 
      echo "<th colspan='9'>";
      echo 'documento de ';echo $COMBO;
      echo "</th>"; 
      echo "</tr>";

        echo "<tr>";
          echo "<th>";
           echo 'IDENTIFICADOR DE DOCUMENTO';
          echo "</th>";
          echo "<th>";
           echo 'ASSUNTO';
          echo "</th>";
          echo "<th>";
           echo 'NUMERO DE DOCUMENTO';
         echo "</th>";
         echo "<th>";
           echo 'IDENTIFICADOR DE UEO';
         echo "</th>";
         echo "<th>";
           echo 'IDENTIFICADOR DE TIPO DE DOCUMENTO';
         echo "</th>";
          echo "<th>";
          echo 'IDENTIFICADOR DE CLASSIFICACAO';
          echo "</th>";
          echo "<th>";
           echo 'NUMERO DE EXEMPLARES';
         echo "</th>";
         echo "<th>";
           echo 'IDENTIFICADOR DE SITUACAO';
         echo "</th>";
         echo "<th>";
           echo 'DATA';
         echo "</th>";
         echo"<th>";
          echo 'IDENTIFICADOR DE TIPO DE REGISTO';
         echo "</th>";
         echo "<th>";
           echo 'EXECUTOR';
         echo "</th>";
         echo "<th>";
           echo "</tr>"; 
           echo "<br>"; 
      echo " Quantidade de Registros: ";



     echo (mysql_num_rows ($resultado) or die ("".mysql_error ())); O ERRO APARECE AQUI NESTA LINHA

     while ($Reg=mysql_fetch_row($resultado))






            {
               echo "<tr>";

             foreach ($Reg as $Val)
                {
                echo "<td>$Val</td> ";
                }
            echo "</tr>";
            }
        echo "</table>";

        mysql_close($con12);
     }
  } 
  ?>
    </td>
  </tr>
</table>
<p align="center">
  <label>Día
  <input type="text" name="TextDia" id="TextDia" size="6" />
  </label>
   vb    
   <label>Hora
<input type="text" name="TextHora" id="TextHora" size="6" />
</label>

  </p>
    </td>
  </tr>
</table>

 <script type="text/javascript">
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"../SpryAssets/SpryMenuBarDownHover.gif", imgRight:"../SpryAssets/SpryMenuBarRightHover.gif"});
</script>
</body>
</html>

Could you help me please? I’m a beginner and this is my first software. I thank you

  • Simple, you are setting the variable $consulta1 and at the time of executing you are wanting to use the variable $consulta which has no value. mysql_query($consulta,$con12); change to mysql_query($consulta1,$con12);

  • 1
  • Hello, thank you so much

  • Thanks so much for the help, I solved the previous error but now I get the following error:Warning: mysql_num_rows() expects Parameter 1 to be Resource, null Given in Unknown column’d. iddocumento' in 'field list' Is there something new wrong with the query? Thanks for the help

  • Thanks so much for the help, I solved the previous error but now I get the following error:Warning: mysql_num_rows() expects Parameter 1 to be Resource, null Given in Unknown column’d. iddocumento' in 'field list' Is there something wrong again in the query? I appreciate the help

No answers

Browser other questions tagged

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