PHP PDO obj works on PHP CLI, but not when page is accessed
As a response to my previous question, I think I may have discovered which part isn't working c开发者_如何学JAVAorrectly. 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?
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.
精彩评论