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 trialMathias nielsen
2,893 PointsCant connect to table film
This is my database.php file:
<?php
//remove before flight
ini_set('display_errors','on');
try{
$db = new PDO('sqlite:./daatabase.db');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}catch(Exception $e){
echo $e->getMessage();
die();
}
?>
And this is my index.php where i try to run the query:
<?php
require_once('database.php');
$results = $db->query('SELECT * FROM film');
var_Dump($results);
die();
?>
2 Answers
thomascawthorn
22,986 PointsCan you give us more info which bit is failing?
It looks like you have a typo in 'database'.
Change:
<?php
$db = new PDO('sqlite:./daatabase.db');
// to
$db = new PDO('sqlite:./database.db');
Also make sure you have the right table name - is it 'film' or 'films'?
Mathias nielsen
2,893 Pointsah, those damn typos!
Thank you, that did the trick :)