Manngo
Manngo

Reputation: 16281

Using PDO to write to SQLite database

I am trying to implement a simple database using PHP & sqlite on my Linux/Apache server.

I can read from it quite readily, but I cannot perform any UPDATE, DELETE or INSERT actions. The Fatal Error I get is:

General error: 5 database is locked

As a simple example:

$pdo=new PDO('sqlite:test.sqlite');
$pdo->exec("INSERT INTO menus(id,name,description) VALUES(6,'test','this is a test')");

This waits for a long time (about a minute), and then reports the above error.

I have read a lot of suggestions, many of which suggest that the database or its containing folder should be writable. They are. (Or were. I made them world writable for testing, and restored more reasonable permissions when that failed.)

I have no trouble writing to the database using other techniques such as the sqlite3 command in Linux and the SQLite manager addon in Firefox.

I would welcome any comments on how to make this work.

Upvotes: 1

Views: 1826

Answers (1)

Leonel Machava
Leonel Machava

Reputation: 1531

Please, try to give the database file a 777 permission and try again. I suspect it has something to do with permissions because you are able to modify the database using sqlite3 program.

If it fails, then try to see the answers to this question.

Upvotes: 1

Related Questions