Error trying to use mysqli_fetch()

Asked

Viewed 109 times

0

I’m trying to use mysqli_fetch() to turn my mysql result 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();
}
  • See in your php.ini if mysqli is enabled

  • I’m sorry but I don’t understand what you mean by php.ini

  • php.ini is a PHP configuration file. It is in the PHP directories of your pc. In it vc enables and disables modules and extensions and apparently your mysqli module is disabled (line should be commented).

  • @Reignomo Tries to replace the function mysqli_fetch for mysqli_fetch_all or mysqli_fetch_array

  • Depending on the version of your php and the modules installed Voce can also get this error.

  • 1

    @Joaopaulo @Reignomo The function mysqli_fetch is deprecated since version 5.4 of PHP

  • Personal vlw switched to mysqli_fetch_array and worked :D

  • Good @Piupz, I didn’t know. I haven’t touched php for years rs. Post as reply to the friend to give as conclusion!

Show 3 more comments

1 answer

0


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

The function can be used for this mysqli_fetch_array.

Example:

$row = mysqli_fetch_array($result, MYSQLI_ASSOC);

In this example a result line will be returned in the form of an associative matrix.

Browser other questions tagged

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