I'm doing a search engine, but this is giving a mistake, I'd like to know the solution.
Follow the code:
<?php
require_once 'conect.php';
if(isset($_POST['submit'])){
$nome = $_POST['nome'];
$pdo = conexao::getInstance();
$parametro = Array(':nome'=>'%'.$nome.'%');
$sql = ' SELECT * FROM doacao WHERE nome LIKE :nome ';
try {
$stmt = $pdo->prepare($sql);
$stmt->bindValue(1, $nome,PDO::PARAM_STR);
$stmt->execute($parametro);
$resultado = $stmt->FETCH(PDOStatement::fetch());
} catch (PDOException $e) {
echo $e->getMessage();
}
echo '<strong>id:</strong> ' , $resultado->iddoacao , '<br />';
echo '<strong>nome:</strong> ' , $resultado->nome , '<br />';
echo '<strong>email:</strong> ' , $resultado->descricao , '<br />';
echo '<strong>criado em:</strong> ', $resultado->dataentrada , '<br />';
}
?>
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<title>Read</title>
<meta charset="iso-8859-1">
</head>
<body>
<h1>Read</h1>
<form action="<?php $_SERVER['PHP_SELF'];?>" method="post">
<div><label for="nome">Nome</label><input type="text" name="nome" id="nome" /></div>
<input type="submit" name="submit" value="Buscar">
</form>
</body>
</html>
the error that is appearing:
Fatal error: Uncaught Error: Non-static method PDOStatement :: fetch () can not be called statically in C: \ xampp \ htdocs \ crudread \ index.php: 15 Stack trace: # 0 {main} thrown in C: \ xampp \ htdocs \ crudread \ index.php on line 15.