Hey I am following a turtorial on Youtube to set up a basic CMS with php and MySQL.
Now I got a fatal error
"Call to a member function fetchAll() on boolean"
even tho' I have been writing the same as in the turtorial. The turtorial I am following is https://www.youtube.com/watch?v=dQ4_eJvnEBc
Here is the code where the fatal error is (list.php):
<?php
require '../app/start.php';
$pages = $db->query("
SELECT id, label, tite, slug
FROM pages
ORDER BY created DESC
")->fetchAll(PDO::FETCH_ASSOC);
var_dump($pages);
The connection to the database is this code (start.php):
<?php
ini_set('display_errors', 'on');
define('APP_ROOT', __DIR__);
define('VIEW_ROOT', APP_ROOT . '/views');
define('BASE_URL', 'http://localhost/myPHP');
$db = new PDO('mysql:host=127.0.0.1;dbname=mycms', 'root', '');
require 'functions.php';
Does anyone know what is causing the fatal error?