SQLite Forum

Select Query will not work in PHP program
Login
As Tim told you, $db is not known in the context of the insertRecord() function. 

It is out of scope of that function. It is the same problem as the first one you posted, where $fatabase was out of scope of the MyDB class constructor.

Stephan is correct, your problem has nothing to do with SQL or SQLite.
It is not even a problem of the PHP wrapper around SQLite, but purely misunderstanding of PHP variable scope.

The error message is quite clear.

```
 Uncaught Error: Call to a member function exec() on null 
```

~~~
-- 
Regards,
Kees Nuyt
~~~