I'm trying to get an id from a database but the following error has come up: Array to string conversion
My code is as follows:
<?php
require 'funciones.php';
$pwd=md5('pwd');
$respuesta = funciones::login('user', $pwd);
if ($respuesta)
{
echo "$respuesta[0];";
}
else
{
echo "Ninguna coincidencia con la busqueda...";
}
?>
And the code of the 'login' function is:
public static function login($user, $pwd)
{
$consultar = "SELECT * FROM login WHERE user = '$user' AND pwd = '$pwd'";
$resultado = Database::getInstance()->getDb()->prepare($consultar);
$resultado->execute();
$tabla = $resultado->fetchAll(PDO::FETCH_ASSOC);
return $tabla;
}
NOTE: The configuration of the database is fine, because if you get a result, the error is in the line: echo "$ answer [0];";