Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Gali Kulakovsky](https://secure.gravatar.com/avatar/b08f64a7c9d6e56f8ce6a5febc0f8a41?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Gali Kulakovsky
2,059 Pointsmy film table is not recognized by compiler and I get the following error:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 1 no such table: film' in /home/treehouse/workspace/index.php:8 Stack trace: #0 /home/treehouse/workspace/index.php(8): PDO->query('select * from f...') #1 {main} thrown in /home/treehouse/workspace/index.php on line 8
any ideas guys? )
my index.php file:
<?php
require_once('database.php');
//remove before flight
ini_set('display_errors', 'On');
$results = $db->query('select * from film');
var_dump($results);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>PHP Data Objects</title>
<link rel="stylesheet" href="style.css">
</head>
<body id="home">
<h1>Sakila Sample Database</h1>
<h2>Films by Title</h2>
<ol>
<li><i class="lens"></i>Film One</li>
<li><i class="lens"></i>Film Two</li>
<li><i class="lens"></i>Film Three</li>
<li><i class="lens"></i>Film Four</li>
</ol>
</body>
</html>
my database.php file:
<?php
try {
$db = new PDO('sqlite:./database.db');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(Exception $e) {
echo $e->getMessage();
die();
}
4 Answers
![Kevin Korte](https://uploads.teamtreehouse.com/production/profile-photos/86647/micro_me.jpg)
Kevin Korte
28,148 PointsUsually, a table name is plural, as it holds many instances of a type of data. So by chance it shouldn't be selecting all from the films table instead?
![thomascawthorn](https://uploads.teamtreehouse.com/production/profile-photos/654142/micro_11350743_1668650660030200_2146547820_n.jpg)
thomascawthorn
22,986 PointsHave you created the tables? You should be able to view all of your created tables with the following command. Throw it in at the top of your script and see what you get back:
<?php
$results = $db->query("SELECT name FROM sqlite_master WHERE type = 'table'");
var_dump($results);
exit;
![Gali Kulakovsky](https://secure.gravatar.com/avatar/b08f64a7c9d6e56f8ce6a5febc0f8a41?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Gali Kulakovsky
2,059 PointsFirst of all thank you for your response!
Have I Created tables? Aren't they suppose to be there already? Have I missed a video where it is shown how to create the tables? I assumed that these tables were suppose to be there with that database.db file that comes on loading the platform from that video . Am I wrong? Anyways your example returns : object(PDOStatement)#2 (1) { ["queryString"]=> string(51) "SELECT name FROM sqlite_master WHERE type = 'table'" } and on $results = $results->fetchAll(); returns array (0) { }
seems like there are no tables there...
![Leonardo Vidal](https://uploads.teamtreehouse.com/production/profile-photos/1238492/micro_1045156_648649168496421_1442743249_n.jpg)
Leonardo Vidal
14,603 PointsWhat happen if you try to get the result from film in the console?
first write: <p>sqlite3 database.db</p>
press enter
,then: <p> select * from film; </p>
![Gali Kulakovsky](https://secure.gravatar.com/avatar/b08f64a7c9d6e56f8ce6a5febc0f8a41?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Gali Kulakovsky
2,059 PointsThanks for trying to help Leonardo.
Running your example returns nothing, three dots like that: ...>
![stef2](https://secure.gravatar.com/avatar/862d53e60d9eab67c06a79b456afc462?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
stef2
11,393 PointsI can't seem to access database.db - had errors on the first video using the console and basically this whole course is now not fit for purpose.
Gali Kulakovsky
2,059 PointsGali Kulakovsky
2,059 Pointstried that and some other table names (in plural too), no luck... same error all the time. First I did exactly how it is shown in the video... should work but it doesn't.