H
H
HPositron2020-11-04 16:04:52
PHP
HPositron, 2020-11-04 16:04:52

Why does PDO execute() on SQLite return false?

I am using PDO with SQLite on PHP 7.2 (OpenServer), when executing the code:

$db = new PDO("sqlite:./resources/main.db");
$user = $db->prepare('SELECT * FROM users WHERE login = ?')->execute(array($_POST['login']))->fetch();

I am getting an error:
Fatal error: Uncaught Error: Call to a member function fetch() on boolean in login.php:14 Stack trace: #0 {main} thrown in login.php on line 14

What is the problem here?
Tried
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- showed nothing.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FanatPHP, 2020-11-04
@HPositron

Because unfortunately you can’t just take and dock fetch to execute

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question