Mysqli查询错误& NUM_ROWS

时间:2014-10-01 13:27:11

标签: php mysqli

我'在我的代码中有两个错误,但我不明白为什么......我有一个类似的代码,它已经准备好了...我的代码是下一个:

   if (isset($_POST['buscandoEducateca'])) {
            //get thevariables
        $buscarEducateca = $_POST['buscarEducateca']; // input text from the form
        $tipoBusquedaEducateca = $_POST['tipoBusqueda'];  //select from the form
            //Start the query
        $consultarEducateca = "SELECT '$tipoBusquedaEducateca' FROM AP1_2_tabla_clientes_Consulta WHERE '$tipoBusquedaEducateca'='$buscarEducateca'";
        $resultadoEducateca = mysqli_query($mysqli, $consultarEducateca); //HERE IS ONE WRONG mysqli_query() expects parameter 1 to be mysqli, null given
        $numeroEducateca = 0;

        $ray2 = mysqli_num_rows($resultadoEducateca); // HERE IS THE OTHER WRONG mysqli_num_rows() expects parameter 1 to be mysqli_result, null given


        if ($ray2 > 0) {

                while($rowNumeroEducateca = $resultadoEducateca->fetch_array(MYSQLI_ASSOC)) {

                echo "<tr><td width=\"25%\"><font face=\"verdana\">" . 
                        $rowNumeroEducateca["Nombre"] . "</font></td>";
               [..more..]   
                $numeroEducateca++;
            }

            echo "<tr><td colspan=\"15\"><font face=\"verdana\"><b>Número: " . $numeroEducateca . 
      "</b></font></td></tr>";  

            mysqli_free_result($resultadoEducateca);
        } else {

            echo "No se han encontrado filas, nada a imprimir.";     // if there aren't something tell me didn't found rows or anything to print, when i know that there are.

        }
    }

还告诉我没有找到要打印的行或任何内容。

谢谢,对不起我的英语。

1 个答案:

答案 0 :(得分:0)

$ mysqli想要先声明。这应该是这样的事情。

$mysqli = mysqli_connect("yourhost","username","password","dbname");