Error de funcion rray()

Ayuden a encontrar el error :frowning:

erro ------> Fatal error: Uncaught Error: Call to a member function fetch_array() on boolean in /storage/ss/6/8/public_html/jaja.php:14 Stack trace: #0 {main} thrown in

<?php
$mysqli = new mysqli("localhost", "id7******", "***********", "*********************j");

/* check connection */
if ($mysqli->connect_errno) {
    printf("Connect failed: %s\n", $mysqli->connect_error);
    exit();
}

$query = "SELECT nombres_completos, nivel FROM alumnos WHERE nombres_completos = 'FIESTAS VITE JUAN JOSE'";
$result = $mysqli->query($query);

/* numeric array */
$row = $result->fetch_array(MYSQLI_NUM);
printf ("%s (%s)\n", $row[0], $row[1]);

/* free result set */
$result->free();

/* close connection */
$mysqli->close();
?>

This is because your query fails.

Try this instead for debugging.

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

if ($result) {
    $row = $result->fetch_array(MYSQLI_NUM);
    printf ("%s (%s)\n", $row[0], $row[1]);
} else {
   exit($mysqli -> error); // this will show the error (if exists)
}
// other code here

After debugging, remember to remove the exit() statement after correcting your error.

1 Like