Problem with database MYSQL + PHP

0

When running this page, I get the following error.

  

Fatal error: Call to undefined function query () in C: \ Program Files \ VertrigoServ \ www \ admin \ admin.php on line 6

My Php Code.

<?php

include("conexao.php");

$consulta = "SELECT * FROM snaps";
$con = $mysqli=query($consulta) or die($mysqli=error);
?>

<html>
    <head>
        <meta charset="utf8">
    </head>
    <body>
        <table>
            <tr>
                <td>Codigo</td>
                <td>Nome</td>
                <td>SnapChat</td>
                <td>Email</td>
                <td>Data de Cadastro</td>
            </tr>
            <?php while($dado = $con->fetch_array()){?>
            <tr>
                <td><?php echo $dado["id"]; ?></td>
                <td><?php echo $dado["nome"]; ?></td>
                <td><?php echo $dado["snapc"]; ?></td>
                <td><?php echo $dado["email"]; ?></td>
                <td><?php echo $dado["created"]; ?></td>
            </tr>
            <?php }?>
        </table>
    </body>
</html>

And this is my Connection.php

<?php
$servidor = "localhost";
$usuario = "root";
$senha = "vertrigo";
$dbname = "snapsje";

//Criar a conexao
$conn = mysqli_connect($servidor, $usuario, $senha, $dbname);
    
asked by anonymous 15.06.2017 / 03:00

1 answer

0

What you're doing here $mysqli=query() is instantiating a variable named mysql and assigning the value returned from the query() function, which I do not think exists in your program.

To fix try this way:

$con = $conn->query($consulta) or die($conn->error);

Or this:

$con = mysqli_query($conn, $consulta) or die(mysqli_error);
    
15.06.2017 / 03:12