1

Is this a correct way of setting up a PDO connection to a SQlite database in php?

new PDO(";dbname=sqlite:c:/path/database.sqlite", "", "");

Because this throws me an error:

PHP Fatal error: Uncaught exception 'PDOException' with message 'could not find driver'

Because whenever I leave the ;dbname= part out, it doesn't give me this error anymore.

So what is the correct way?

PS: I have set up the drivers correctly in php.ini, see this link for a screenshot of phpinfo(): http://puu.sh/2xtEF.jpg

2
  • Run phpinfo() and check your drivers. Commented Apr 10, 2013 at 14:59
  • Sorry for not mentioning, but I already have set up all my drivers correctly. I will edit the question. Commented Apr 10, 2013 at 15:07

1 Answer 1

3

Seems like if you leave the ;dbname= part, it's just the hostname (DSN). So it should be either

"sqlite:c:/path/database.sqlite"

or

"sqlite:c:/path/database.sqlite;dbname=whateverthenameis"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.