Error trying to use mysqli_fetch ()

0

I'm trying to use mysqli_fetch () to transform my result from mysql into an array but php returns me the following message: Fatal error: Call to undefined function mysqli_fetch ()

This is the function I'm using

public function PopulaPerfil()
{
    include("conexao.php");

    $cd = $_SESSION['cd_usuario'];
    $query ="SELECT * FROM tb_usuario WHERE cd_usuario = '$cd' ";
    $result = mysqli_query($conexao,$query);
    $resultArray= mysqli_fetch($result);
    return $resultArray;
    die();
}
    
asked by anonymous 14.06.2018 / 18:44

1 answer

0

As commented out, the mysqli_fetch function is deprecated and has been removed since version 5.4 of PHP.

To do this you can use the mysqli_fetch_array function.

Example:

$row = mysqli_fetch_array($result, MYSQLI_ASSOC);

In this example, a result row will be returned as an associative array.

    
14.06.2018 / 19:06