Error Php Comments

0

Hi guys, I have this little mistake, they could help me solve it.

if ($conexion)
{
    $resultado = mysql_query("SELECT id, usuario, fecha, mensaje FROM comentarios ORDER BY id DESC", $conexion);
    while ($fila = mysql_fetch_row($resultado))
    {
        echo "<B>Mensaje</B> #" . $fila[0] . "; ";
        echo "<B>Escrito por:</B> " . $fila[1] . "; ";
        echo "<B>Fecha:</B> " . $fila[2] . "; ";
        echo "<BR>";
        echo $fila[3];
        echo "<HR>";
    }
}
  

Warning: mysql_fetch_row () expects parameter 1 to be resource, boolean   given in C: \ xampp \ htdocs \ comments.php on line 66

    
asked by MarcuzVon 10.11.2017 в 23:38
source

1 answer

1

$resultado is false. It means that something failed. That you can debugge it as

$resultado = mysql_query("SELECT id, usuario, fecha, mensaje FROM comentarios ORDER BY id DESC", $conexion);

if (!$resultado) {
    die('Consulta no válida: ' . mysql_error());
}

But instead of repairing that code, I would recommend you to look for a more modern tutorial. The time you spend learning to use the old and abandoned mysql connector is time lost.

    
answered by 10.11.2017 / 23:42
source