2
Hey, guys, good afternoon. I’m having trouble connecting by Bindvalue to my variable, note that I made the call, asked to return the values with Fetchall and it is returning an empty array. When I use normally without the bindValue it works. Could someone help me?
Code:
try {
$conexao = new PDO("mysql:dbname=test;host=localhost" , "root", "");
$nome = $_POST['nome'];
$comando = $conexao ->prepare("select * from usuario where nome like '%:nome%'");
$comando ->bindValue(':nome', $nome);
$comando ->execute();
$inf = $comando ->fetchAll();
print_r($inf);
} catch (PDOException $ex){
echo 'Erro: ' .$ex->getCode() . '<br>';
echo 'Mensagem de erro: ' .$ex->getMessage();
}
Hello, enter the code in the question and not a print. I recommend to reading
– renanvm
Thanks for the tip
– gabrieltec97