Sqlite insert

I’m trying to write a simple Sqlite application using PDO library and am having trouble with my insert. I have

$query = $db->prepare("INSERT INTO users (firstname, lastname, phone) VALUES (:firstname, :lastname, :phone)");
$query->execute(array(':firstname'=>$firstname, ':lastname'=>$lastname, ':phone'=>$phone));

but when I execute the code I get
Fatal error: Call to a member function execute() on a non-object
Can anyone enlighten me where I’m going wrong please…

Do you have resource defined?

$db = new PDO("mysql:host=localhost;dbname=$dbname", "$login", "$dbpass");

Are you 100% sure of these names meaning no uppercase letters?

users (firstname, lastname, phone) 

Yes, I have

$db = new PDO('sqlite:users.sqlite');

and yes all fields are lowercase.

I’ve solved my problem using Sqlite3 without PDO.