Error in line mysql_fetch_array [closed]

0

This is an information search engine for universities, my CBT. This is the error:

$mysqlli=newmysqli($servidor,$user,$senha,$banco);if(mysqli_connect_errno())trigger_error(mysqli_connect_error());elseecho"sucesso";

//@mysql_select_db("faculdadesbd",$mysqlli);

? > Unigle     body {         font-family: Verdana, Geneva, sans-serif;         color: # 333;         font-size: 12px;     }


<?php
    if(isset($_POST['botao'])){
        $busca = $_POST['busca'];

        $busca_dividida = explode(' ',$busca);
        $quant = count($busca_dividida);

        for($i=0;$i<$quant;$i++){
            $pesquisa = $busca_dividida[$i];

            $sql = ("SELECT * FROM busca WHERE nome_fac LIKE '%$.pesquisa.%'");
            $query = $mysqlli->query($sql);
            while($linha = mysql_fetch_array($sql)){
                $nome_fac = $linha['Nome'];
                $data_vest = $linha['Data Vestibular'];
                $data_taxa = $linha['Data Taxa'];
                $nota_corte = $linha['Nota de corte'];
                $nota_enem = $linha['Nota ENEM'];

                echo"
                    <div class='resultado'>
                        <h2>".$nome_fac."</h2>
                        <p>".$data_vest."</p>
                        <p>".$data_taxa."</p>
                        <p>".$nota_corte."</p>
                        <p>".$nota_enem."</p>
                    </div>
                    ";
        }
    }
    }
?>

    
asked by anonymous 22.11.2014 / 16:19

1 answer

1

It seems to be just a typo, its connection object is $mysqlli , and at the time of calling the query() method you call a variable that does not exist $mysqli . To fix change the call from:

$query = $mysqli->query($sql);

by:

$query = $mysqlli->query($sql);

When a blank screen is displayed, this means two things an error has occurred and the display of errors has been hidden (usually for security reasons). In this case it is possible for errors overwriting this setting, the following lines should be at the beginning of your file.

 <?php
 ini_set('display_errors', true);
 error_reporting(E_ALL);

 echo '...';

The line below can be removed, and avoid using @ because it hides the errors, which makes it harder to resolve the bug.

@mysql_select_db("faculdadesbd",$mysqlli);
    
22.11.2014 / 17:01