So, this is the function that makes the connection:
function criarConexao(){
$conexao = new PDO('mysql:host=localhost; dbname=quiquestoes', 'root', '');
$conexao->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$conexao->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $conexao;
}
Basically, I use the following function to search a value in the database and return the result:
function buscarQuestao($id){
$conexao = criarConexao();
$sql= "select * from questao where idQuestao = :id;";
$sentence = $conexao->prepare($sql);
$sentence->bindvalue(':id', $id);
$sentence->execute();
$conexao = null;
$questao = $sentence->fetch();
return $questao;
}
And when I call this function like
$questao = buscarQuestao($id);
print_r($questao);
it is returning null.
The code worked properly a few days ago, but now it just stoped. Why it isn't working? I tried unistalling and installing xampp again, restarting the computer.
This is the statement after the ->bindvalue():
PDOStatement Object ( [queryString] => select * from questao where idQuestao = :id; )
Sorry for any grammar mistakes, english is not my first language.