0
I have a form that does a search via PDO, only when I run, it does not return me anything.
$PDO = db_connect();
$busca = $_POST['usuario'];
$vbusca = "%".$busca."%";
$sql = 'SELECT nome, tipo, cor FROM livro AS t WHERE ';
var_dump($sql);
$stmt = $PDO->prepare($sql);
$stmt->execute([$vbusca]);
$total = $stmt->rowCount();
I gave one var_dump
in the variable $stmt
and is returning me the following:
string(57) "SELECT name, type, color FROM book AS t WHERE" Object(Pdostatement)#2 (1) { ["queryString"]=> string(57) "SELECT name, type, color FROM book AS t WHERE" }
How is the connection made with the bank? And not a var_dump on
$sql
and yes in the$total
– Guilherme Rigotti
string(57) "SELECT name, type, color FROM book AS t WHERE" int(0)
– Teresa Santos
Did not miss the field by receiving the value after the WHERE?
WHERE busca = ?
– Fabiano Monteiro
Your select is wrong, missed the column and condition in the WHERE.
– Guilherme Rigotti
@Guilhermerigotti as I can do to search the 3 columns?
– Teresa Santos