|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-10-14 13:13 UTC] tony2001@php.net
[2005-10-14 15:55 UTC] Bjorn dot Wiberg at its dot uu dot se
[2005-10-19 00:48 UTC] iliaa@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 13:00:01 2025 UTC |
Description: ------------ If the path to the database to be created or opened does not have "read" (directory listing) rights all the way, sqlite_open() fails. Presumably because of getcwd() usage. If one specifies the full path to the database file to be opened or created, everything appears to work just fine. Similarly, if one makes sure that "read" rights are present all the way, everything appears to work just fine as well. I do not know if this is specific to PHP+sqlite or to SQLite itself. I'm using the bundled SQLite (automatically detected during ./configure). Reproduce code: --------------- <?php if ($db = sqlite_open('mysqlitedb', 0666, $sqliteerror)) { //if ($db = sqlite_open('./mysqlitedb', 0666, $sqliteerror)) { //if ($db = sqlite_open(dirname(__FILE__) . '/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); } ?> Expected result: ---------------- Successful creation of the database in all cases: array(2) { [0]=> string(5) "fnord" ["bar"]=> string(5) "fnord" } Actual result: -------------- CASE 1 (open "mysqldb"): Warning: sqlite_open(): unable to open database: mysqlitedb in /apache/htdocs/bwiberg/test/sqlite/sqlite.php on line 2 unable to open database: mysqlitedb CASE 2 (open "./mysqldb"): Warning: sqlite_open(): unable to open database: ./mysqlitedb in /apache/htdocs/bwiberg/test/sqlite/sqlite.php on line 3 unable to open database: ./mysqlitedb CASE 3 (open with full path): array(2) { [0]=> string(5) "fnord" ["bar"]=> string(5) "fnord" }