Packiya Rajan
Packiya Rajan

Reputation: 59

SQLite throws "undefined function sqlite_open()"

I am developing a Desktop application using Titanium in PHP. I am a PHP Web Developer with MySQL DB, new to Desktop with SQLite DB

When I try to open the SQLite DB , it throws a fatal error

the code I used is

if ($db = sqlite_open('mysqlitedb', 0666, $sqliteerror)) {
    sqlite_query($db, 'CREATE TABLE foo (bar varchar(10))');
    sqlite_query($db, "INSERT INTO foo VALUES ('fnord')");
    $result = sqlite_query($db, 'select bar from foo');
    var_dump(sqlite_fetch_array($result));
} else {
    die($sqliteerror);
}

just the example code in PHP.net

PHP.net says that SQLite is bundled with PHP 5+

the error thrown only in TItanium Studio where as

in my XAMPP it all works fine

Could you help?

Upvotes: 0

Views: 3062

Answers (1)

Ariel
Ariel

Reputation: 404

The PHP manual page for SQLite's requirements says: The SQLite extension is enabled by default as of PHP 5.0. Beginning with PHP 5.4, the SQLite extension is available only via PECL.

You may want to check out the version of PHP in use by Titanium Studio.

I've never used this particular IDE before, but this is typically what I do when looking for version and module-related information for PHP:

  1. Find the PHP binary (php.exe, php, php5, php-cgi, etc). (Use your O.S. tools to find it)
  2. Run $PHP_BINARY -v to get the binary's version info.
  3. Run $PHP_BINARY -m to get a printout of enabled modules for PHP.
  4. If sqlite is not listed among the loaded modules, see if it's present in the directory pointed by the extension_dir configuration directive (in php.ini).
  5. If the module is present as a file, add a line stating extension = $NAME_OF_SQLITE_FILE (usually php_sqlite.so or php_sqlite.dll) and see if sqlite_open() now works.
  6. If the module is not present, see if you can get a pre-compiled binary from the maintainers of the IDE, or if they have specific instructions to build the extension from source.

Upvotes: 2

Related Questions