tags:

views:

22

answers:

1

As a response to my previous question, I think I may have discovered which part isn't working correctly. I have a small section of PHP code which uses a PDO object to add to a sqlite3 database that is used in a AJAX call.

When this code is executed using the php cli by issuing the command: "php add.php" everything works as expected and adds and entry to the table. However when I access this php file by it's web address, nothing is added to the table.

$base = new PDO('sqlite:todo.db');
$sql = $base->prepare("INSERT INTO Tasks (content) VALUES ('testdata');");
$sql->execute();
echo "done";

"done" will appear at the command line, as well as on the webpage. Can anyone explain this strange behavior to me?

+3  A: 

There are many possible explanations for this, but I'll venture to guess that the web user doesn't have access to write to the sqlite database file.

troelskn
Wow, simple as that huh? I can't believe I spent like 2 days trying to fix this and didn't consider this possibility. Thanks so much!
Kevin
You're welcome. Is now the appropriate time to advice you *not* to use sqlite for a webapp, because it doesn't cope well (eg. at all) with concurrent users?
troelskn