fatal error on :new SQLiteDatabase

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi all,

as a matter of testing i deliberately  changed the unix permissions so
that www-data cannot write the development folder.

Now if the permissions are correct , the below works fine . but if wrong
instead of working as expected it triggers

Uncaught exception 'SQLiteException' with message
unable to open database: /home/trookat/public_html/.htsql' in

I have tried error suppression using @ but his just hides the error and
browser get a blank result.
I may be too tired and missing something simple.

function sqlsetup()
   if (defined('DEBUG')) $this->debug("sql setup");
   if (!$sqldb = new SQLiteDatabase(DBFILE,0666, $error))   // error line
    $errorst = (file_exists(DBFILE)) ? "Cannot to open, check
permissions" : "Cannot create, check permissions";
    $errorst.= " : ".$error;
    $this->coreerror($errorst); // display error nicely
   if (defined('DEBUG')) $this->debug("sql setup--Success");

error repoting is  (E_ALL | E_STRICT)
I may have to run off an learn how to check the working directory
permissions , but I'm looking to understand if I have done anything wrong.


Re: fatal error on :new SQLiteDatabase

trookat escribió:
Quoted text here. Click to load it

What are you trying to accomplish? A read-only database? Have you
created the /home/trookat/public_html/.htsql database first?

Quoted text here. Click to load it

Yep, that's the supposed behaviour of the @ operator. To deal with
exceptions you use the exception handling syntax:

}catch(Exception $e){


-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com

Re: fatal error on :new SQLiteDatabase

Álvaro G. Vicario wrote:
Quoted text here. Click to load it

I have a working engine .SQLiteDatabase creates the file if does not
exist. I deleted the file and set the write permissions off in the
working directory to test if my code was working correctly.

SQLiteDatabase should return false if it fails but instead it is
throwing and fatal error .

Quoted text here. Click to load it

I am well aware of error catchment  however according to
testing the result is all that is required
Note i am using the php5-sqlite  package not a 3rd party extension ( pdo
or otherwise )

The puzzle is i should get a result even if the permissions are
incorrect , instead of a fatal error.

in any case ive been looking at using filperms  (
http://au.php.net/fileperms ) as a precheck .however its a solution that
shouldn't be needed.


Re: fatal error on :new SQLiteDatabase

trookat wrote:
Quoted text here. Click to load it

You are confusing the function interface with the object interface.
sqlite-open() would return false.  But a constructor cannot return true
or false; the only way it can signal a failure is to throw an exception.

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Re: fatal error on :new SQLiteDatabase

Jerry Stuckle wrote:
Quoted text here. Click to load it

Thankyou Jerry.that makes sense
testing proves you are correct.


Site Timeline