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

PHP PHP & Databases with PDO Getting Started With PDO Introductions

Richard Hope
Richard Hope
25,237 Points

Using sqlite3 with my website.

Up until now I've been learning by building my own website and was using mysql as per previous tutorials on databases and php. I'd like to use sqlite3 with my website having seen this as my database will be very small and it seems like a better solution than mysql.

I've downloaded the sqlite3 files and put them in a folder on my c drive, have exported a table from excel and created a database using sqlite studio and that database is in my inc folder.

I can't work out how I start using the database with my console and the php doesn't seem to be linking to the database.

--code added--

<?php

require_once('../inc/config.php');

// remove before flight

ini_set('display_errors', 'on');

try { $db = new PDO('sqlite:' . ROOT_PATH . 'inc/pricelist.db'); var_dump($db); die(); } catch(Exception $e) { echo $e->getMessage(); die(); }

When i refresh my webpage it does show : object(PDO)#1 (0) { }

but when try to break the code by changing the filename it displays the same thing.

Can you please post the code you're currently using to try and connect to your database?

2 Answers

can you do some research on whether sqlite is worthy of being a production database? just to be sure as i have heard to the contrary.