Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[resolved] SQLite in PHP4

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
User avatar
mority
Posts: 75
Joined: 2005-07-28 07:47

[resolved] SQLite in PHP4

#1 Post by mority »

Hello board,

I am planning to work on a PHP application in a Debian sid environment. In this application I would like to use the SQLite library to store some data. As it is really not much data to store and as I want to be independent from a database server I would like to avoid using a real database system like MySQL. I really like the idea of using SQLite as a middle way between MySQL and storing the data in a plain text file.

Now my problem is, that the SQLite functions seem to work only in PHP5 at least that's what the documentation on php.net says. On the description page to every single SQLite function there is the major PHP version given in parantheses at the top of the page, and there is always PHP5 and never PHP4 (like here).

On the other hand there is a package in Debian sid called "php4-sqlite". That gave me some hope and I ignored the php.net documentation, installed the package and tried

Code: Select all

<?php sqlite_open(foo); ?>
But that gives me nothing than
Fatal error: Call to undefined function: sqlite_open() in path/index.php on line 1
So it seems php.net is proved correct and the functions really work exclusively in PHP5. But if so, what is the php4-sqlite package good for anyways? Is there still a way to get SQLite running with PHP4? I really would like to avoid installing PHP5 by hand and give up the convinient apt-get upgrade service.

Oh, my exact Apache and PHP versions are: Apache/2.0.54 (Debian GNU/Linux) PHP/4.3.10-15 (just the current versions in Debian sid...)

Regards,
mority

UPDATE:

Now, I am really confused. I found a nice source for all PHP5 packages through apt-get.org (deb http://people.debian.org/~dexter php5 sid). So I installed all the php5 packages from this source and it works just fine. phpinfo() says
PHP Version 5.0.4-0.10 (Debian GNU/Linux)
But now, and that's what I don't understand at all, I get the same error message for

Code: Select all

sqlite_open(foo);
as I got with PHP4 installed (Call to undefined function blah... see above). Of course I installed the php5-sqlite package, too. Now I'm sad.
Last edited by mority on 2005-07-29 09:09, edited 1 time in total.

lacek
Posts: 764
Joined: 2004-03-11 18:49
Location: Budapest, Hungary
Contact:

#2 Post by lacek »

The official packages in Sarge (version 4.3.10) are capable of handling SQLite databases. You need to install the php4-sqlite package, and either:
- Load the sqlite module by writing this line to your php script:

Code: Select all

dl("sqlite.so");
- or load the module by adding it to /etc/php4/apache2/php.ini by adding the

Code: Select all

extension=sqlite.so
line and restart apache.
Last edited by lacek on 2005-07-28 13:00, edited 1 time in total.

User avatar
mority
Posts: 75
Joined: 2005-07-28 07:47

#3 Post by mority »

Thanks for the fast response. Unfortunately it doesn't work nevertheless.

I tried both of your suggestions:

First one:

Code: Select all

nestor:~# cat /etc/php5/apache2/php.ini | grep sqlite.so
extension=sqlite.so
nestor:~# apache2ctl restart
nestor:~# 
Outcome: I still get the same "Call to undefined function" error.

Second One:

Code: Select all

<?php 
dl("sqlite.so");
$db = sqlite_open(foo);
?>
Outcome:
Warning: dl() [function.dl]: Unable to load dynamic library '/usr/lib/php5/20041030/sqlite.so' - /usr/lib/php5/20041030/sqlite.so: undefined symbol: ps_globals in /home/mo/myfiles/cvs/mreiter/public_html/avc-dev/index.php on line 2

Fatal error: Call to undefined function sqlite_open() in /home/mo/myfiles/cvs/mreiter/public_html/avc-dev/index.php on line 3

User avatar
mority
Posts: 75
Joined: 2005-07-28 07:47

#4 Post by mority »

Well, it works now, but I don't really know why.

I purged everything on my system which has to do with sqlite and then reinstalled the php5-sqlite package and it worked.

I assume that there was a conflict because I had sqlite and sqlite3 installed so the Apache could not load the proper module or it tried to load the sqlite3 library and failed as I read it is not compatible to PHP5. I don't know.

alfem

Works, but you must reload the server

#5 Post by alfem »

I don't know why, but installing php4-sqlite package doesn't alter php.ini, so you have to add it by hand.

Restart apache and everything works !

Post Reply