PHP - Error por codigo con tabla html

 
Vista:

Error por codigo con tabla html

Publicado por frvncsk (1 intervención) el 29/01/2020 16:07:42
Tengo un error de un arrays y no entiendo porque, lo que tengo que hacer es una tabla que muestre los ultimos 10 registros.
Dejo el error
Fatal error: Call to a member function fetch_array() on boolean in /home/presta15/public_html/-Dominios-subdominios/Francisca.rambal.com/Prueba.php on line 32

y dejo codigo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
$servername = "localhost";
$dbname = "";// REPLACE with your Database name
$username = "";// REPLACE with Database user
$password = "";// REPLACE with Database user password
 
$conexion = new mysqli($servername, $username, $password, $dbname);
 
if($conexion->connect_errno)
{
    echo "Error de conexion de la base datos".$conexion->connect_error;
    exit();
}
$sql = "select * from temperatura order by id desc LIMIT 15";
 
$resultado = $conexion->query($sql);
?>
 
<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
    <h1 align="center">Listado Temp</h1>
    <table width="70%" border="1px" align="center">
 
    <tr align="center">
        <td>Temperatura</td>
    </tr>
    <?php
        while($datos=$resultado->fetch_array()){
        ?>
            <tr>
                <td><?php echo $datos["tem1"]?></td>
            </tr>
            <?php
        }
 
     ?>
    </table>
 
</body>
</html>
ayuda
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder