PHP - PDO - Sqlite - HY000

PHP - PDO - Sqlite - HY000

by Ping Zhang -
Number of replies: 2

Hi there,

I try to use the PDO to connect to sqlite database.

The query function (SELECT) works well. But INSERT does not work. The PDO error code is HY000.

I believe it is cased by the PHP program does not have write permission. 

May someone know how to fix this problem?

All the best,


In reply to Ping Zhang

Re: PHP - PDO - Sqlite - HY000

by Richard Lobb -
It sounds like you are supplying an sqlite3 database file as one of the Support Files in the question. If that's the case, then indeed all files supplied by the question author are write protected. This is essential for security - you don't want students writing code that modifies files used in testing their code!

The solution is simple, however. You just need to modify the template so that it makes a copy of the database file before each test is run, and use the copy for sqlite3, not the original. For an example of how it's done, create a new SQL question, click "Customise" and inspect the template.
In reply to Richard Lobb

Re: PHP - PDO - Sqlite - HY000

by Ping Zhang -
Thanks Richard for timely response. I have add the copy code for PHP template, it works now!